diff --git a/lib/libc/string/memmem.c b/lib/libc/string/memmem.c index 27863b9db623..9e7bf94b1464 100644 --- a/lib/libc/string/memmem.c +++ b/lib/libc/string/memmem.c @@ -153,8 +153,8 @@ twoway_memmem(const unsigned char *h, const unsigned char *z, if (BITOP(byteset, h[l - 1], &)) { k = l - shift[h[l - 1]]; if (k) { - if (mem0 && mem && k < p) - k = l - p; + if (k < mem) + k = mem; h += k; mem = 0; continue;