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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user