From bcc90106305609bddad93bb4c61390f77d83c3d7 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Tue, 12 Jul 2016 11:53:51 +0300 Subject: [PATCH] fixed memory leak in flann tests --- modules/flann/src/miniflann.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/modules/flann/src/miniflann.cpp b/modules/flann/src/miniflann.cpp index 7d81438db..b7661752c 100644 --- a/modules/flann/src/miniflann.cpp +++ b/modules/flann/src/miniflann.cpp @@ -318,7 +318,19 @@ buildIndex_(void*& index, const Mat& data, const IndexParams& params, const Dist ::cvflann::Matrix dataset((ElementType*)data.data, data.rows, data.cols); IndexType* _index = new IndexType(dataset, get_params(params), dist); - _index->buildIndex(); + + try + { + _index->buildIndex(); + } + catch (...) + { + delete _index; + _index = NULL; + + throw; + } + index = _index; }