diff options
author | Rich Felker <dalias@aerifal.cx> | 2025-05-16 09:10:19 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2025-05-16 09:11:14 -0400 |
commit | ae3a8c93a663b553e65f096498937083dad210d2 (patch) | |
tree | f30256d8ada8b92a9a48daf7676565d6ee593ac4 | |
parent | 23febbd3c5d6b4e367faee4f39b8e8c3b95ab588 (diff) | |
download | musl-master.tar.gz |
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.
-rw-r--r-- | src/string/strcasestr.c | 1 |
1 files changed, 1 insertions, 0 deletions
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; } |