Fixed UBSan warning about undefined pointer arithmetic overflow

Pointer arithmetic overflow is always undefined, whether signed or unsigned.

It warned here:

`Addition of unsigned offset to 0x00017fd31b97 overflowed to 0x00017fd30c97`

Convert the offset to a signed number, so that we can offset either forward or backwards.

In my own use of OpenCV at least, this is the only case of pointer arithmetic overflow.
This commit is contained in:
Sean McBride 2023-05-20 14:39:06 -04:00
parent a8d3d1f6f9
commit 2083fdc9c0

View File

@ -44,6 +44,8 @@
#include "opencv2/core/hal/intrin.hpp"
#include "filter.hpp"
#include <cstddef>
#if defined(CV_CPU_BASELINE_MODE)
#if IPP_VERSION_X100 >= 710
#define USE_IPP_SEP_FILTERS 1
@ -304,7 +306,7 @@ void FilterEngine__apply(FilterEngine& this_, const Mat& src, Mat& dst, const Si
FilterEngine__start(this_, wsz, src.size(), ofs);
int y = this_.startY - ofs.y;
FilterEngine__proceed(this_,
src.ptr() + y*src.step,
src.ptr() + y * (ptrdiff_t)src.step,
(int)src.step,
this_.endY - this_.startY,
dst.ptr(),