diff --git a/modules/imgproc/src/drawing.cpp b/modules/imgproc/src/drawing.cpp old mode 100755 new mode 100644 index a0cd8ae772..cbd238aca9 --- a/modules/imgproc/src/drawing.cpp +++ b/modules/imgproc/src/drawing.cpp @@ -1556,7 +1556,7 @@ Circle( Mat& img, Point center, int radius, const void* color, int fill ) ICV_HLINE( tptr1, x21, x22, color, pix_size ); } } - else if( x11 < size.width && x12 >= 0 && y21 < size.height && y22 >= 0 ) + else if( x11 < size.width && x12 >= 0 && y21 < size.height && y22 >= 0) { if( fill ) { @@ -1564,7 +1564,7 @@ Circle( Mat& img, Point center, int radius, const void* color, int fill ) x12 = MIN( x12, size.width - 1 ); } - if( (unsigned)y11 < (unsigned)size.height ) + if( y11 >= 0 && y11 < size.height ) { uchar *tptr = ptr + y11 * step; @@ -1579,7 +1579,7 @@ Circle( Mat& img, Point center, int radius, const void* color, int fill ) ICV_HLINE( tptr, x11, x12, color, pix_size ); } - if( (unsigned)y12 < (unsigned)size.height ) + if( y12 >= 0 && y12 < size.height ) { uchar *tptr = ptr + y12 * step; @@ -1602,7 +1602,7 @@ Circle( Mat& img, Point center, int radius, const void* color, int fill ) x22 = MIN( x22, size.width - 1 ); } - if( (unsigned)y21 < (unsigned)size.height ) + if( y21 >= 0 && y21 < size.height ) { uchar *tptr = ptr + y21 * step; @@ -1617,7 +1617,7 @@ Circle( Mat& img, Point center, int radius, const void* color, int fill ) ICV_HLINE( tptr, x21, x22, color, pix_size ); } - if( (unsigned)y22 < (unsigned)size.height ) + if( y22 >= 0 && y22 < size.height ) { uchar *tptr = ptr + y22 * step; diff --git a/modules/imgproc/test/test_drawing.cpp b/modules/imgproc/test/test_drawing.cpp index 8afd0e0072..23208ab881 100644 --- a/modules/imgproc/test/test_drawing.cpp +++ b/modules/imgproc/test/test_drawing.cpp @@ -913,4 +913,12 @@ INSTANTIATE_TEST_CASE_P( ) ); +TEST(Drawing, circle_overflow) +{ + applyTestTag(CV_TEST_TAG_VERYLONG); + cv::Mat1b matrix = cv::Mat1b::zeros(600, 600); + cv::Scalar kBlue = cv::Scalar(0, 0, 255); + cv::circle(matrix, cv::Point(275, -2147483318), 2147483647, kBlue, 1, 8, 0); +} + }} // namespace