]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-10036: add back in patch from FS-4285. Still need to address this upstream
authorMike Jerris <mike@jerris.com>
Thu, 9 Mar 2017 02:50:21 +0000 (20:50 -0600)
committerMike Jerris <mike@jerris.com>
Thu, 9 Mar 2017 02:50:34 +0000 (20:50 -0600)
libs/esl/src/cJSON.c
libs/libks/src/cJSON.c
src/cJSON.c

index 7f9ecb3b4c5964177045680727e81fbfbe3a23b1..c804b8a476f3db3c474efb37b471ba37a117b7ce 100644 (file)
@@ -92,18 +92,14 @@ static unsigned char* cJSON_strdup(const unsigned char* str, const internal_hook
 {
     size_t len = 0;
     unsigned char *copy = NULL;
+       const unsigned char *s = str ? str : (unsigned char *)"";
 
-    if (str == NULL)
-    {
-        return NULL;
-    }
-
-    len = strlen((const char*)str) + 1;
+    len = strlen((const char*)s) + 1;
     if (!(copy = (unsigned char*)hooks->allocate(len)))
     {
         return NULL;
     }
-    memcpy(copy, str, len);
+    memcpy(copy, s, len);
 
     return copy;
 }
index b5c2ef01001952ecbd5b706a19bf1bfe546dd48a..2c9581210482ffb3ad02c92b4d8247573f10d53e 100644 (file)
@@ -92,18 +92,14 @@ static unsigned char* cJSON_strdup(const unsigned char* str, const internal_hook
 {
     size_t len = 0;
     unsigned char *copy = NULL;
+       const unsigned char *s = str ? str : (unsigned char *)"";
 
-    if (str == NULL)
-    {
-        return NULL;
-    }
-
-    len = strlen((const char*)str) + 1;
+    len = strlen((const char*)s) + 1;
     if (!(copy = (unsigned char*)hooks->allocate(len)))
     {
         return NULL;
     }
-    memcpy(copy, str, len);
+    memcpy(copy, s, len);
 
     return copy;
 }
index cb1f9971a2a382f6c4e1879102fc4953f2ed0cca..85709f1e3be699c73395d195b4794c2ae0166611 100644 (file)
@@ -92,18 +92,14 @@ static unsigned char* cJSON_strdup(const unsigned char* str, const internal_hook
 {
     size_t len = 0;
     unsigned char *copy = NULL;
+       const unsigned char *s = str ? str : (unsigned char *)"";
 
-    if (str == NULL)
-    {
-        return NULL;
-    }
-
-    len = strlen((const char*)str) + 1;
+    len = strlen((const char*)s) + 1;
     if (!(copy = (unsigned char*)hooks->allocate(len)))
     {
         return NULL;
     }
-    memcpy(copy, str, len);
+    memcpy(copy, s, len);
 
     return copy;
 }