mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-21 11:30:01 +00:00
Fix build - NULL pointer check
This commit is contained in:
1 parent
4c356bc368
commit
20c5da6e55
2 files changed
+2
No files matched your search
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user