Skip to content

Commit

Permalink
Merge pull request opencv#12443 from DEEPIR:master
Browse files Browse the repository at this point in the history
* simplify condition

* dims must > 0 or latter sz[dims-1] will underflow
  • Loading branch information
cyyever authored and alalek committed Sep 6, 2018
1 parent f1f1584 commit 8b48c2a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions modules/core/src/arithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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'" );
Expand Down
2 changes: 1 addition & 1 deletion modules/core/src/copy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 8b48c2a

Please sign in to comment.