From: Ilya Lavrenov Date: Thu, 3 Sep 2015 10:25:29 +0000 (+0300) Subject: fixed uninitialized memory writing/reading in flann X-Git-Tag: accepted/tizen/6.0/unified/20201030.111113~1314^2~161^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3934d61de7d34e9ac8040cf5ced349a51ad2e520;p=platform%2Fupstream%2Fopencv.git fixed uninitialized memory writing/reading in flann --- diff --git a/modules/flann/include/opencv2/flann/kmeans_index.h b/modules/flann/include/opencv2/flann/kmeans_index.h index 9c0f4e2..e119ceb 100644 --- a/modules/flann/include/opencv2/flann/kmeans_index.h +++ b/modules/flann/include/opencv2/flann/kmeans_index.h @@ -384,6 +384,8 @@ public: } root_ = pool_.allocate(); + std::memset(root_, 0, sizeof(KMeansNode)); + computeNodeStatistics(root_, indices_, (int)size_); computeClustering(root_, indices_, (int)size_, branching_,0); } @@ -823,11 +825,11 @@ private: variance -= distance_(centers[c], ZeroIterator(), veclen_); node->childs[c] = pool_.allocate(); + std::memset(node->childs[c], 0, sizeof(KMeansNode)); node->childs[c]->radius = radiuses[c]; node->childs[c]->pivot = centers[c]; node->childs[c]->variance = variance; node->childs[c]->mean_radius = mean_radius; - node->childs[c]->indices = NULL; computeClustering(node->childs[c],indices+start, end-start, branching, level+1); start=end; }