Skip to content

Commit 773262b

Browse files
Federico Martinezalalek
authored andcommitted
Fix UB in CopyMakeConstBoder_8u
Caused by overflow of arithmetic operators conversion rank
1 parent 20a46b3 commit 773262b

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

modules/core/src/copy.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1325,13 +1325,12 @@ void copyMakeConstBorder_8u( const uchar* src, size_t srcstep, cv::Size srcroi,
13251325
memcpy( dstInner + srcroi.width, constBuf, right );
13261326
}
13271327

1328-
dst += dststep*top;
1329-
13301328
for( i = 0; i < top; i++ )
1331-
memcpy(dst + (i - top)*dststep, constBuf, dstroi.width);
1329+
memcpy(dst + i * dststep, constBuf, dstroi.width);
13321330

1331+
dst += (top + srcroi.height) * dststep;
13331332
for( i = 0; i < bottom; i++ )
1334-
memcpy(dst + (i + srcroi.height)*dststep, constBuf, dstroi.width);
1333+
memcpy(dst + i * dststep, constBuf, dstroi.width);
13351334
}
13361335

13371336
}

0 commit comments

Comments
 (0)