Fixed Assertin error due to Size.area() overflowing

pull/11722/head
gnthibault 7 years ago
parent 1187a7fa34
commit b46fef327e
  1. 10
      modules/imgproc/src/resize.cpp

@ -3672,7 +3672,7 @@ void resize(int src_type,
{
CV_INSTRUMENT_REGION()
CV_Assert((dst_width * dst_height > 0) || (inv_scale_x > 0 && inv_scale_y > 0));
CV_Assert((dst_width > 0 && dst_height > 0) || (inv_scale_x > 0 && inv_scale_y > 0));
if (inv_scale_x < DBL_EPSILON || inv_scale_y < DBL_EPSILON)
{
inv_scale_x = static_cast<double>(dst_width) / src_width;
@ -3684,7 +3684,7 @@ void resize(int src_type,
int depth = CV_MAT_DEPTH(src_type), cn = CV_MAT_CN(src_type);
Size dsize = Size(saturate_cast<int>(src_width*inv_scale_x),
saturate_cast<int>(src_height*inv_scale_y));
CV_Assert( dsize.area() > 0 );
CV_Assert( !dsize.empty() );
CV_IPP_RUN_FAST(ipp_resize(src_data, src_step, src_width, src_height, dst_data, dst_step, dsize.width, dsize.height, inv_scale_x, inv_scale_y, depth, cn, interpolation))
@ -4041,13 +4041,13 @@ void cv::resize( InputArray _src, OutputArray _dst, Size dsize,
Size ssize = _src.size();
CV_Assert( ssize.width > 0 && ssize.height > 0 );
CV_Assert( dsize.area() > 0 || (inv_scale_x > 0 && inv_scale_y > 0) );
CV_Assert( !ssize.empty() );
CV_Assert( !dsize.empty() || (inv_scale_x > 0 && inv_scale_y > 0) );
if( dsize.area() == 0 )
{
dsize = Size(saturate_cast<int>(ssize.width*inv_scale_x),
saturate_cast<int>(ssize.height*inv_scale_y));
CV_Assert( dsize.area() > 0 );
CV_Assert( !dsize.empty() );
}
else
{

Loading…
Cancel
Save