mirror of
https://github.com/cesanta/mongoose.git
synced 2025-01-14 09:48:01 +08:00
Fix build - NULL pointer check
This commit is contained in:
parent
4c356bc368
commit
20c5da6e55
@ -4930,6 +4930,7 @@ const char *mg_strstr(const struct mg_str haystack,
|
||||
const struct mg_str needle) {
|
||||
size_t i;
|
||||
if (needle.len > haystack.len) return NULL;
|
||||
if (needle.len == 0) return haystack.ptr;
|
||||
for (i = 0; i <= haystack.len - needle.len; i++) {
|
||||
if (memcmp(haystack.ptr + i, needle.ptr, needle.len) == 0) {
|
||||
return haystack.ptr + i;
|
||||
|
@ -74,6 +74,7 @@ const char *mg_strstr(const struct mg_str haystack,
|
||||
const struct mg_str needle) {
|
||||
size_t i;
|
||||
if (needle.len > haystack.len) return NULL;
|
||||
if (needle.len == 0) return haystack.ptr;
|
||||
for (i = 0; i <= haystack.len - needle.len; i++) {
|
||||
if (memcmp(haystack.ptr + i, needle.ptr, needle.len) == 0) {
|
||||
return haystack.ptr + i;
|
||||
|
Loading…
x
Reference in New Issue
Block a user