tweaks: avoid the subtraction of two size_t variables becoming negative

This fixes https://savannah.gnu.org/bugs/?60658.

Found by compiling with -fsanitize=undefined.
This commit is contained in:
Benno Schulenberg 2021-05-23 11:46:37 +02:00
parent d1957819c4
commit ceaae49b2d

View File

@ -540,7 +540,7 @@ char *mbrevstrcasestr(const char *haystack, const char *needle,
size_t tail_len = mbstrlen(pointer);
if (tail_len < needle_len)
pointer += tail_len - needle_len;
pointer -= (needle_len - tail_len);
if (pointer < haystack)
return NULL;