Fix build - NULL pointer check

This commit is contained in:
cpq committed 2023-02-28 17:55:25 +00:00
1 parent 4c356bc368
commit 20c5da6e55
2 files changed
+2

No files matched your search

+1
View File
@@ -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;
+1
View File
@@ -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;