From: Mike Jerris Date: Thu, 9 Mar 2017 02:50:21 +0000 (-0600) Subject: FS-10036: add back in patch from FS-4285. Still need to address this upstream X-Git-Tag: v1.8.0~762 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e4e4fd2f9fb03b25fb73124db33c40c8200fb37f;p=thirdparty%2Ffreeswitch.git FS-10036: add back in patch from FS-4285. Still need to address this upstream --- diff --git a/libs/esl/src/cJSON.c b/libs/esl/src/cJSON.c index 7f9ecb3b4c..c804b8a476 100644 --- a/libs/esl/src/cJSON.c +++ b/libs/esl/src/cJSON.c @@ -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; } diff --git a/libs/libks/src/cJSON.c b/libs/libks/src/cJSON.c index b5c2ef0100..2c95812104 100644 --- a/libs/libks/src/cJSON.c +++ b/libs/libks/src/cJSON.c @@ -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; } diff --git a/src/cJSON.c b/src/cJSON.c index cb1f9971a2..85709f1e3b 100644 --- a/src/cJSON.c +++ b/src/cJSON.c @@ -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; }