mirror of
https://github.com/opencv/opencv.git
synced 2025-08-06 14:36:36 +08:00
Don't overflow pointer addition
In both cases we add negative value (as unsigned type), so pointer addition wraps, which is undefined behavior.
This commit is contained in:
parent
796adf5dc6
commit
e76924ef0d
@ -955,7 +955,7 @@ static void remapBicubic( const Mat& _src, Mat& _dst, const Mat& _xy,
|
|||||||
sum += S[0]*w[8] + S[cn]*w[9] + S[cn*2]*w[10] + S[cn*3]*w[11];
|
sum += S[0]*w[8] + S[cn]*w[9] + S[cn*2]*w[10] + S[cn*3]*w[11];
|
||||||
S += sstep;
|
S += sstep;
|
||||||
sum += S[0]*w[12] + S[cn]*w[13] + S[cn*2]*w[14] + S[cn*3]*w[15];
|
sum += S[0]*w[12] + S[cn]*w[13] + S[cn*2]*w[14] + S[cn*3]*w[15];
|
||||||
S += 1 - sstep*3;
|
S -= sstep * 3 - 1;
|
||||||
D[k] = castOp(sum);
|
D[k] = castOp(sum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -988,9 +988,9 @@ static void remapBicubic( const Mat& _src, Mat& _dst, const Mat& _xy,
|
|||||||
for(int i = 0; i < 4; i++, w += 4 )
|
for(int i = 0; i < 4; i++, w += 4 )
|
||||||
{
|
{
|
||||||
int yi = y[i];
|
int yi = y[i];
|
||||||
const T* S = S0 + yi*sstep;
|
|
||||||
if( yi < 0 )
|
if( yi < 0 )
|
||||||
continue;
|
continue;
|
||||||
|
const T* S = S0 + yi*sstep;
|
||||||
if( x[0] >= 0 )
|
if( x[0] >= 0 )
|
||||||
sum += (S[x[0]] - cv)*w[0];
|
sum += (S[x[0]] - cv)*w[0];
|
||||||
if( x[1] >= 0 )
|
if( x[1] >= 0 )
|
||||||
|
Loading…
Reference in New Issue
Block a user