From 2de8487e5844a11a99bad39925bb2074be747ed3 Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Fri, 6 Sep 2013 15:53:42 +0400 Subject: [PATCH 1/2] Fixed a few tests that use uninitialized inputs. --- modules/imgproc/test/test_imgwarp.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/imgproc/test/test_imgwarp.cpp b/modules/imgproc/test/test_imgwarp.cpp index 4ea3b76ba8..53f7d5c2fc 100644 --- a/modules/imgproc/test/test_imgwarp.cpp +++ b/modules/imgproc/test/test_imgwarp.cpp @@ -1424,7 +1424,7 @@ TEST(Imgproc_fitLine_vector_2d, regression) TEST(Imgproc_fitLine_Mat_2dC2, regression) { - cv::Mat mat1(3, 1, CV_32SC2); + cv::Mat mat1 = Mat::zeros(3, 1, CV_32SC2); std::vector line1; cv::fitLine(mat1, line1, CV_DIST_L2, 0 ,0 ,0); @@ -1444,7 +1444,7 @@ TEST(Imgproc_fitLine_Mat_2dC1, regression) TEST(Imgproc_fitLine_Mat_3dC3, regression) { - cv::Mat mat1(2, 1, CV_32SC3); + cv::Mat mat1 = Mat::zeros(2, 1, CV_32SC3); std::vector line1; cv::fitLine(mat1, line1, CV_DIST_L2, 0 ,0 ,0); @@ -1454,7 +1454,7 @@ TEST(Imgproc_fitLine_Mat_3dC3, regression) TEST(Imgproc_fitLine_Mat_3dC1, regression) { - cv::Mat mat2(2, 3, CV_32SC1); + cv::Mat mat2 = Mat::zeros(2, 3, CV_32SC1); std::vector line2; cv::fitLine(mat2, line2, CV_DIST_L2, 0 ,0 ,0); From 4f109d12924d1ac5e097e3fec707274cfbb5d7ec Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Fri, 6 Sep 2013 16:02:41 +0400 Subject: [PATCH 2/2] Fixed a memory access error in CV_Remap_Test::generate_test_data. begin_x[1] is not the second component of the element, but the element after the one pointed to begin_x. When begin_x points to the last element, that line overwrites data past the end of the allocation, which, during my tests, happened to contain the reference count for the matrix. Hilarity ensues. --- modules/imgproc/test/test_imgwarp_strict.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/imgproc/test/test_imgwarp_strict.cpp b/modules/imgproc/test/test_imgwarp_strict.cpp index 59b851c45e..064ba93568 100644 --- a/modules/imgproc/test/test_imgwarp_strict.cpp +++ b/modules/imgproc/test/test_imgwarp_strict.cpp @@ -679,8 +679,8 @@ void CV_Remap_Test::generate_test_data() MatIterator_ begin_x = mapx.begin(), end_x = mapx.end(); for ( ; begin_x != end_x; ++begin_x) { - begin_x[0] = static_cast(rng.uniform(static_cast(_n), std::max(src.cols + n - 1, 0))); - begin_x[1] = static_cast(rng.uniform(static_cast(_n), std::max(src.rows + n - 1, 0))); + (*begin_x)[0] = static_cast(rng.uniform(static_cast(_n), std::max(src.cols + n - 1, 0))); + (*begin_x)[1] = static_cast(rng.uniform(static_cast(_n), std::max(src.rows + n - 1, 0))); } if (interpolation != INTER_NEAREST)