提交 e4e4fd2f authored 作者: Mike Jerris's avatar Mike Jerris

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

上级 53aab765
...@@ -92,18 +92,14 @@ static unsigned char* cJSON_strdup(const unsigned char* str, const internal_hook ...@@ -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;
} }
......
...@@ -92,18 +92,14 @@ static unsigned char* cJSON_strdup(const unsigned char* str, const internal_hook ...@@ -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;
} }
......
...@@ -92,18 +92,14 @@ static unsigned char* cJSON_strdup(const unsigned char* str, const internal_hook ...@@ -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;
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论