tweaks: prevent two more size_t subtractions from going negative

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

Found by compiling with -fsanitize=undefined.
master
Benno Schulenberg 2021-05-24 11:00:29 +02:00
parent b38f0cbaf4
commit 30bafc70cc
1 changed files with 2 additions and 2 deletions

View File

@ -498,7 +498,7 @@ char *revstrstr(const char *haystack, const char *needle,
size_t tail_len = strlen(pointer);
if (tail_len < needle_len)
pointer += tail_len - needle_len;
pointer -= (needle_len - tail_len);
while (pointer >= haystack) {
if (strncmp(pointer, needle, needle_len) == 0)
@ -518,7 +518,7 @@ char *revstrcasestr(const char *haystack, const char *needle,
size_t tail_len = strlen(pointer);
if (tail_len < needle_len)
pointer += tail_len - needle_len;
pointer -= (needle_len - tail_len);
while (pointer >= haystack) {
if (strncasecmp(pointer, needle, needle_len) == 0)