Skip to content

Commit 19f1bac

Browse files
committed
Merge pull request opencv#19603 from federicohml:fix-ub-copy-make-const-border-8u
2 parents b3b80f8 + 773262b commit 19f1bac

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)