Skip to content

Commit

Permalink
fixed memory leak in descriptor regression tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ilya-lavrenov authored and Dikay900 committed Sep 13, 2015
1 parent f7d36bb commit cf0f47f
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions modules/features2d/test/test_descriptors_regression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ static void writeMatInBin( const Mat& mat, const string& filename )
fwrite( (void*)&mat.rows, sizeof(int), 1, f );
fwrite( (void*)&mat.cols, sizeof(int), 1, f );
fwrite( (void*)&type, sizeof(int), 1, f );
int dataSize = (int)(mat.step * mat.rows * mat.channels());
int dataSize = (int)(mat.step * mat.rows);
fwrite( (void*)&dataSize, sizeof(int), 1, f );
fwrite( (void*)mat.ptr(), 1, dataSize, f );
fclose(f);
Expand All @@ -82,13 +82,14 @@ static Mat readMatFromBin( const string& filename )
int step = dataSize / rows / CV_ELEM_SIZE(type);
CV_Assert(step >= cols);

Mat m = Mat(rows, step, type).colRange(0, cols);
Mat returnMat = Mat(rows, step, type).colRange(0, cols);

size_t elements_read = fread( m.ptr(), 1, dataSize, f );
size_t elements_read = fread( returnMat.ptr(), 1, dataSize, f );
CV_Assert(elements_read == (size_t)(dataSize));

fclose(f);

return m;
return returnMat;
}
return Mat();
}
Expand Down

0 comments on commit cf0f47f

Please sign in to comment.