Commit 4f109d12 authored by Roman Donchenko's avatar Roman Donchenko

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.
parent 2de8487e
......@@ -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)
......
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