From af01267f23a2016232e78ceb747654a29481c02c Mon Sep 17 00:00:00 2001 From: Vladislav Sovrasov Date: Wed, 2 Nov 2016 14:17:56 +0300 Subject: [PATCH] Add assertion to prevent processing of large images in remap --- modules/imgproc/include/opencv2/imgproc.hpp | 2 ++ modules/imgproc/src/imgwarp.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/modules/imgproc/include/opencv2/imgproc.hpp b/modules/imgproc/include/opencv2/imgproc.hpp index 7d51c34dcb..fe52898424 100644 --- a/modules/imgproc/include/opencv2/imgproc.hpp +++ b/modules/imgproc/include/opencv2/imgproc.hpp @@ -2286,6 +2286,8 @@ not supported by this function. borderMode=BORDER_TRANSPARENT, it means that the pixels in the destination image that corresponds to the "outliers" in the source image are not modified by the function. @param borderValue Value used in case of a constant border. By default, it is 0. +@note +Due to current implementaion limitations the size of an input and output images should be less than 32767x32767. */ CV_EXPORTS_W void remap( InputArray src, OutputArray dst, InputArray map1, InputArray map2, diff --git a/modules/imgproc/src/imgwarp.cpp b/modules/imgproc/src/imgwarp.cpp index 08424363f4..9cf53a12f2 100644 --- a/modules/imgproc/src/imgwarp.cpp +++ b/modules/imgproc/src/imgwarp.cpp @@ -4856,6 +4856,8 @@ void cv::remap( InputArray _src, OutputArray _dst, Mat src = _src.getMat(), map1 = _map1.getMat(), map2 = _map2.getMat(); _dst.create( map1.size(), src.type() ); Mat dst = _dst.getMat(); + CV_Assert( dst.cols < SHRT_MAX && dst.rows < SHRT_MAX && src.cols < SHRT_MAX && src.rows < SHRT_MAX ); + if( dst.data == src.data ) src = src.clone();