FS-10036: add back in patch from FS-4285. Still need to address this upstream

This commit is contained in:
Mike Jerris 2017-03-08 20:50:21 -06:00
parent 53aab765d8
commit e4e4fd2f9f
3 changed files with 9 additions and 21 deletions

View File

@ -92,18 +92,14 @@ static unsigned char* cJSON_strdup(const unsigned char* str, const internal_hook
{ {
size_t len = 0; size_t len = 0;
unsigned char *copy = NULL; unsigned char *copy = NULL;
const unsigned char *s = str ? str : (unsigned char *)"";
if (str == NULL) len = strlen((const char*)s) + 1;
{
return NULL;
}
len = strlen((const char*)str) + 1;
if (!(copy = (unsigned char*)hooks->allocate(len))) if (!(copy = (unsigned char*)hooks->allocate(len)))
{ {
return NULL; return NULL;
} }
memcpy(copy, str, len); memcpy(copy, s, len);
return copy; return copy;
} }

View File

@ -92,18 +92,14 @@ static unsigned char* cJSON_strdup(const unsigned char* str, const internal_hook
{ {
size_t len = 0; size_t len = 0;
unsigned char *copy = NULL; unsigned char *copy = NULL;
const unsigned char *s = str ? str : (unsigned char *)"";
if (str == NULL) len = strlen((const char*)s) + 1;
{
return NULL;
}
len = strlen((const char*)str) + 1;
if (!(copy = (unsigned char*)hooks->allocate(len))) if (!(copy = (unsigned char*)hooks->allocate(len)))
{ {
return NULL; return NULL;
} }
memcpy(copy, str, len); memcpy(copy, s, len);
return copy; return copy;
} }

View File

@ -92,18 +92,14 @@ static unsigned char* cJSON_strdup(const unsigned char* str, const internal_hook
{ {
size_t len = 0; size_t len = 0;
unsigned char *copy = NULL; unsigned char *copy = NULL;
const unsigned char *s = str ? str : (unsigned char *)"";
if (str == NULL) len = strlen((const char*)s) + 1;
{
return NULL;
}
len = strlen((const char*)str) + 1;
if (!(copy = (unsigned char*)hooks->allocate(len))) if (!(copy = (unsigned char*)hooks->allocate(len)))
{ {
return NULL; return NULL;
} }
memcpy(copy, str, len); memcpy(copy, s, len);
return copy; return copy;
} }