From ae3a8c93a663b553e65f096498937083dad210d2 Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Fri, 16 May 2025 09:10:19 -0400 Subject: fix strcasestr failing to find zero-length needle the loop condition ending on end-of-haystack ends before a zero-length needle can be matched, so just explicitly check it before the loop. --- src/string/strcasestr.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/string/strcasestr.c b/src/string/strcasestr.c index af109f36..dc598bc3 100644 --- a/src/string/strcasestr.c +++ b/src/string/strcasestr.c @@ -4,6 +4,7 @@ char *strcasestr(const char *h, const char *n) { size_t l = strlen(n); + if (!l) return (char *)h; for (; *h; h++) if (!strncasecmp(h, n, l)) return (char *)h; return 0; } -- cgit v1.2.1