Skip to content

Commit

Permalink
Fix an off-by-one error of own memrchr implementation
Browse files Browse the repository at this point in the history
and make it support `search_len == 0`, just for the case

Ref [Bug #20796]
  • Loading branch information
mame committed Oct 21, 2024
1 parent 257f78f commit a83c91d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions string.c
Original file line number Diff line number Diff line change
Expand Up @@ -4548,9 +4548,9 @@ static void*
memrchr(const char *search_str, int chr, long search_len)
{
const char *ptr = search_str + search_len;
do {
while (ptr > search_str) {
if ((unsigned char)*(--ptr) == chr) return (void *)ptr;
} while (ptr >= search_str);
}

return ((void *)0);
}
Expand Down

0 comments on commit a83c91d

Please sign in to comment.