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.
This commit is contained in:
Roman Donchenko 2013-09-06 16:02:41 +04:00
parent 2de8487e58
commit 4f109d1292

View File

@ -679,8 +679,8 @@ void CV_Remap_Test::generate_test_data()
MatIterator_<Vec2s> begin_x = mapx.begin<Vec2s>(), end_x = mapx.end<Vec2s>();
for ( ; begin_x != end_x; ++begin_x)
{
begin_x[0] = static_cast<short>(rng.uniform(static_cast<int>(_n), std::max(src.cols + n - 1, 0)));
begin_x[1] = static_cast<short>(rng.uniform(static_cast<int>(_n), std::max(src.rows + n - 1, 0)));
(*begin_x)[0] = static_cast<short>(rng.uniform(static_cast<int>(_n), std::max(src.cols + n - 1, 0)));
(*begin_x)[1] = static_cast<short>(rng.uniform(static_cast<int>(_n), std::max(src.rows + n - 1, 0)));
}
if (interpolation != INTER_NEAREST)