Skip to content

Commit fadb25b

Browse files
committed
imgproc(warpAffine): avoid buffer indexes overflow in SIMD code
1 parent 20a46b3 commit fadb25b

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

modules/imgproc/src/imgwarp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ struct RemapVec_8u
446446
{
447447
int cn = _src.channels(), x = 0, sstep = (int)_src.step;
448448

449-
if( (cn != 1 && cn != 3 && cn != 4) || sstep > 0x8000 )
449+
if( (cn != 1 && cn != 3 && cn != 4) || sstep >= 0x8000 )
450450
return 0;
451451

452452
const uchar *S0 = _src.ptr(), *S1 = _src.ptr(1);

modules/imgproc/test/test_imgwarp.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1781,6 +1781,26 @@ TEST(Imgproc_Warp, multichannel)
17811781
}
17821782
}
17831783

1784+
1785+
TEST(Imgproc_Warp, regression_19566) // valgrind should detect problem if any
1786+
{
1787+
const Size imgSize(8192, 8);
1788+
1789+
Mat inMat = Mat::zeros(imgSize, CV_8UC4);
1790+
Mat outMat = Mat::zeros(imgSize, CV_8UC4);
1791+
1792+
warpAffine(
1793+
inMat,
1794+
outMat,
1795+
getRotationMatrix2D(Point2f(imgSize.width / 2.0f, imgSize.height / 2.0f), 45.0, 1.0),
1796+
imgSize,
1797+
INTER_LINEAR,
1798+
cv::BORDER_CONSTANT,
1799+
cv::Scalar(0.0, 0.0, 0.0, 255.0)
1800+
);
1801+
}
1802+
1803+
17841804
TEST(Imgproc_GetAffineTransform, singularity)
17851805
{
17861806
Point2f A_sample[3];

0 commit comments

Comments
 (0)