mirror of
https://github.com/DaveGamble/cJSON.git
synced 2023-08-10 21:13:26 +03:00
cJSON_Raw: Additional checks in print_value
This commit is contained in:
parent
9ef44fc0b6
commit
ddadb44a67
18
cJSON.c
18
cJSON.c
@ -990,12 +990,26 @@ static char *print_value(const cJSON *item, int depth, cjbool fmt, printbuffer *
|
|||||||
out = print_number(item, p);
|
out = print_number(item, p);
|
||||||
break;
|
break;
|
||||||
case cJSON_Raw:
|
case cJSON_Raw:
|
||||||
out = ensure(p, strlen(item->valuestring));
|
{
|
||||||
|
size_t raw_length = 0;
|
||||||
|
if (item->valuestring == NULL)
|
||||||
|
{
|
||||||
|
if (!p->noalloc)
|
||||||
|
{
|
||||||
|
cJSON_free(p->buffer);
|
||||||
|
}
|
||||||
|
out = NULL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
raw_length = strlen(item->valuestring) + sizeof('\0');
|
||||||
|
out = ensure(p, raw_length);
|
||||||
if (out)
|
if (out)
|
||||||
{
|
{
|
||||||
strcpy(out, item->valuestring);
|
memcpy(out, item->valuestring, raw_length);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case cJSON_String:
|
case cJSON_String:
|
||||||
out = print_string(item, p);
|
out = print_string(item, p);
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user