Skip to content

Commit 00c05de

Browse files
committed
Merge pull request flann-lib#284 from tkoeppe/master
Fix memory leaks in kmeans_index.h
2 parents b8a442f + c7075bc commit 00c05de

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/cpp/flann/algorithms/kmeans_index.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,7 @@ class KMeansIndex : public NNIndex<Distance>
416416
Index* obj = static_cast<Index*>(ar.getObject());
417417

418418
if (Archive::is_loading::value) {
419+
delete[] pivot;
419420
pivot = new DistanceType[obj->veclen_];
420421
}
421422
ar & serialization::make_binary_object(pivot, obj->veclen_*sizeof(DistanceType));
@@ -524,6 +525,7 @@ class KMeansIndex : public NNIndex<Distance>
524525

525526
node->variance = variance;
526527
node->radius = radius;
528+
delete node->pivot;
527529
node->pivot = mean;
528530
}
529531

0 commit comments

Comments
 (0)