From: Ilya Lavrenov Date: Tue, 1 Sep 2015 13:17:18 +0000 (+0300) Subject: fixed memory leak in flann index X-Git-Tag: accepted/tizen/6.0/unified/20201030.111113~1314^2~162^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=32d7c1950a562d038ff6f8b810ee46298a83fc39;p=platform%2Fupstream%2Fopencv.git fixed memory leak in flann index --- diff --git a/modules/flann/src/miniflann.cpp b/modules/flann/src/miniflann.cpp index 5ce3e90..9bf5033 100644 --- a/modules/flann/src/miniflann.cpp +++ b/modules/flann/src/miniflann.cpp @@ -318,12 +318,14 @@ buildIndex_(void*& index, const Mat& wholedata, const Mat& data, const IndexPara ::cvflann::Matrix dataset((ElementType*)data.data, data.rows, data.cols); - IndexType* _index = NULL; - if( !index || getParam(params, "algorithm", FLANN_INDEX_LINEAR) != FLANN_INDEX_LSH) // currently, additional index support is the lsh algorithm only. + // currently, additional index support is the lsh algorithm only. + if( !index || getParam(params, "algorithm", FLANN_INDEX_LINEAR) != FLANN_INDEX_LSH) { - _index = new IndexType(dataset, get_params(params), dist); + Ptr _index = makePtr(dataset, get_params(params), dist); _index->buildIndex(); index = _index; + // HACK to prevent object destruction + _index.obj = NULL; } else // build additional lsh index {