1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 15:53:03 +04:00

Added more strict checks for empty inputs to compare, meanStdDev and RNG::fill

This commit is contained in:
Maksim Shabunin
2018-07-18 15:24:58 +03:00
parent fa466b022d
commit 1165fdd0f5
7 changed files with 35 additions and 107 deletions
+2 -1
View File
@@ -1233,7 +1233,8 @@ void cv::compare(InputArray _src1, InputArray _src2, OutputArray _dst, int op)
CV_Assert( op == CMP_LT || op == CMP_LE || op == CMP_EQ ||
op == CMP_NE || op == CMP_GE || op == CMP_GT );
if(_src1.empty() || _src2.empty())
CV_Assert(_src1.empty() == _src2.empty());
if (_src1.empty() && _src2.empty())
{
_dst.release();
return;
+2 -1
View File
@@ -411,7 +411,8 @@ Mat& Mat::operator = (const Scalar& s)
{
CV_INSTRUMENT_REGION()
if (empty()) return *this;
if (this->empty())
return *this;
const Mat* arrays[] = { this };
uchar* dptr;
+3 -1
View File
@@ -766,11 +766,13 @@ void cv::meanStdDev( InputArray _src, OutputArray _mean, OutputArray _sdv, Input
{
CV_INSTRUMENT_REGION()
CV_Assert(!_src.empty());
CV_Assert( _mask.empty() || _mask.type() == CV_8UC1 );
CV_OCL_RUN(OCL_PERFORMANCE_CHECK(_src.isUMat()) && _src.dims() <= 2,
ocl_meanStdDev(_src, _mean, _sdv, _mask))
Mat src = _src.getMat(), mask = _mask.getMat();
CV_Assert( mask.empty() || mask.type() == CV_8UC1 );
CV_OVX_RUN(!ovx::skipSmallImages<VX_KERNEL_MEAN_STDDEV>(src.cols, src.rows),
openvx_meanStdDev(src, _mean, _sdv, mask))
+2 -2
View File
@@ -511,8 +511,8 @@ static RandnScaleFunc randnScaleTab[] =
void RNG::fill( InputOutputArray _mat, int disttype,
InputArray _param1arg, InputArray _param2arg, bool saturateRange )
{
if (_mat.empty())
return;
CV_Assert(!_mat.empty());
Mat mat = _mat.getMat(), _param1 = _param1arg.getMat(), _param2 = _param2arg.getMat();
int depth = mat.depth(), cn = mat.channels();
AutoBuffer<double> _parambuf;