From the Coverity Scan (impact High):
 	
CID 1058549 (#1 of 1): Non-array delete for scalars (DELETE_ARRAY)
9. delete_var: Deleting array variable "dist" with non-array delete in "delete dist". 

I think you meant to use delete[] dist here.