RT #132552
when hopping N characters along a string, if the 'end stop' lim wasn't
on a char boundary, the value returned by S_reghop3() could be up to
(but not including) one char's worth of bytes beyond lim.
This is fairly harmless, but gave valgrind/ASan palpitations.
So fixed by this commit.
if (off >= 0) {
while (off-- && s < lim) {
/* XXX could check well-formedness here */
- s += UTF8SKIP(s);
+ U8 *new_s = s + UTF8SKIP(s);
+ if (new_s > lim) /* lim may be in the middle of a long character */
+ return s;
+ s = new_s;
}
}
else {
/(?xx)[a b]/x \N{SPACE} n - -
/(?-x:[a b])/xx \N{SPACE} yS $& # Note a space char here
^a?bcd\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff ABCDEFGHIJKLMNOPQRSTUVWXYZ n - - # [perl #132187] for valgrind's benefit
+^Xaaa?Xaa aaa\x{400000} n - - # [perl #132552] for valgrind's benefit
# Keep these lines at the end of the file
# vim: softtabstop=0 noexpandtab