Fixed issue #33

This commit is contained in:
bzt 2022-03-29 18:39:46 +02:00
parent f9249ab0b6
commit 1ebaf59a90

View file

@ -95,7 +95,7 @@ void *memmem(const void *haystack, size_t hl, const void *needle, size_t nl)
{ {
uint8_t *c = (uint8_t*)haystack; uint8_t *c = (uint8_t*)haystack;
if(!haystack || !needle || !hl || !nl || nl > hl) return NULL; if(!haystack || !needle || !hl || !nl || nl > hl) return NULL;
hl -= nl; hl -= nl - 1;
while(hl) { while(hl) {
if(!memcmp(c, needle, nl)) return c; if(!memcmp(c, needle, nl)) return c;
c++; hl--; c++; hl--;