Commit 8b48c2a1 authored by cyy's avatar cyy Committed by Alexander Alekhin

Merge pull request #12443 from DEEPIR:master

* simplify condition

* dims must > 0 or latter sz[dims-1] will underflow
parent f1f15841
......@@ -617,7 +617,7 @@ static void arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst,
if( (kind1 == kind2 || cn == 1) && sz1 == sz2 && dims1 <= 2 && dims2 <= 2 && type1 == type2 &&
!haveMask && ((!_dst.fixedType() && (dtype < 0 || CV_MAT_DEPTH(dtype) == depth1)) ||
(_dst.fixedType() && _dst.type() == type1)) &&
((src1Scalar && src2Scalar) || (!src1Scalar && !src2Scalar)) )
(src1Scalar == src2Scalar) )
{
_dst.createSameSize(*psrc1, type1);
CV_OCL_RUN(use_opencl,
......@@ -1257,7 +1257,7 @@ void cv::compare(InputArray _src1, InputArray _src2, OutputArray _dst, int op)
compare(_src2, _src1, _dst, op);
return;
}
else if( (is_src1_scalar && is_src2_scalar) || (!is_src1_scalar && !is_src2_scalar) )
else if(is_src1_scalar == is_src2_scalar)
CV_Error( CV_StsUnmatchedSizes,
"The operation is neither 'array op array' (where arrays have the same size and the same type), "
"nor 'array op scalar', nor 'scalar op array'" );
......
......@@ -258,7 +258,7 @@ void Mat::copyTo( OutputArray _dst ) const
UMat dst = _dst.getUMat();
CV_Assert(dst.u != NULL);
size_t i, sz[CV_MAX_DIM] = {0}, dstofs[CV_MAX_DIM], esz = elemSize();
CV_Assert(dims >= 0 && dims < CV_MAX_DIM);
CV_Assert(dims > 0 && dims < CV_MAX_DIM);
for( i = 0; i < (size_t)dims; i++ )
sz[i] = size.p[i];
sz[dims-1] *= esz;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment