Commit f7d36bba authored by Ilya Lavrenov's avatar Ilya Lavrenov Committed by Dikay900

fixed memory leaks in modules/features2d/test/test_nearestneighbors.cpp

parent d81a0df4
...@@ -161,7 +161,7 @@ void NearestNeighborTest::run( int /*start_from*/ ) { ...@@ -161,7 +161,7 @@ void NearestNeighborTest::run( int /*start_from*/ ) {
class CV_FlannTest : public NearestNeighborTest class CV_FlannTest : public NearestNeighborTest
{ {
public: public:
CV_FlannTest() {} CV_FlannTest() : NearestNeighborTest(), index(NULL) { }
protected: protected:
void createIndex( const Mat& data, const IndexParams& params ); void createIndex( const Mat& data, const IndexParams& params );
int knnSearch( Mat& points, Mat& neighbors ); int knnSearch( Mat& points, Mat& neighbors );
...@@ -172,6 +172,9 @@ protected: ...@@ -172,6 +172,9 @@ protected:
void CV_FlannTest::createIndex( const Mat& data, const IndexParams& params ) void CV_FlannTest::createIndex( const Mat& data, const IndexParams& params )
{ {
// release previously allocated index
releaseModel();
index = new Index( data, params ); index = new Index( data, params );
} }
...@@ -238,7 +241,11 @@ int CV_FlannTest::radiusSearch( Mat& points, Mat& neighbors ) ...@@ -238,7 +241,11 @@ int CV_FlannTest::radiusSearch( Mat& points, Mat& neighbors )
void CV_FlannTest::releaseModel() void CV_FlannTest::releaseModel()
{ {
delete index; if (index)
{
delete index;
index = NULL;
}
} }
//--------------------------------------- //---------------------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment