mirror of
https://github.com/opencv/opencv.git
synced 2025-08-05 22:19:14 +08:00
Fix overlow pointers.
`step` and `maskStep` are used to increase/decrease `pImage`. But it's done on unsigned type, relying on overflow, which is UB. (step is size_t but seed.y is int and can be negative, the result is therefore unsigned which can overflow)
This commit is contained in:
parent
df5da4abcd
commit
c5f6ed6fef
@ -283,7 +283,7 @@ floodFillGrad_CnIR( Mat& image, Mat& msk,
|
||||
Diff diff, ConnectedComp* region, int flags,
|
||||
std::vector<FFillSegment>* buffer )
|
||||
{
|
||||
size_t step = image.step, maskStep = msk.step;
|
||||
auto step = static_cast<std::ptrdiff_t>(image.step), maskStep = static_cast<std::ptrdiff_t>(msk.step);
|
||||
uchar* pImage = image.ptr();
|
||||
_Tp* img = (_Tp*)(pImage + step*seed.y);
|
||||
uchar* pMask = msk.ptr() + maskStep + sizeof(_MTp);
|
||||
|
Loading…
Reference in New Issue
Block a user