It is UB to apply a distance to a pointer or iterator further than the
end itself, even if the distance is (partially) revoked later on.
Fix the issue by advancing the data pointer at most to the end.
https://eel.is/c++draft/expr.add#4
When an expression J that has integral type is added to [...] an expression P of pointer type, the result has the type of P.
... if P points to a (possibly-hypothetical) array element i of an array object x with n elements [...] the expressions P + J and J + P (where J has the value j) point to the (possibly-hypothetical) array element i+j of x if 0≤i+j≤n [...]
Otherwise, the behavior is undefined.
This is a partial backport of core#31655
https://github.com/bitcoin/bitcoin/pull/31655/commits/fabeca3458b38a3d8930cb0cbc866388c3f120f1