Adds a necessary search restart to custom strcasestr().

Previously needle "ab" would not be found in haystack "aab".
This commit is contained in:
nnposter 2018-08-25 22:39:36 +00:00
parent 6725a34200
commit d22dbc63b8

View file

@ -171,8 +171,10 @@ char *strcasestr(const char *haystack, const char *pneedle) {
free(needle);
return (char *)(p - needlelen + 1);
}
} else
} else {
p -= foundto - needle;
foundto = needle;
}
}
if (needlelen >= sizeof(buf))
free(needle);