mirror of
https://github.com/DaveGamble/cJSON.git
synced 2023-08-10 21:13:26 +03:00
fix bug: 2859459 (crash when printing JSON)
handling of string length was incorrect. git-svn-id: http://svn.code.sf.net/p/cjson/code@8 e3330c51-1366-4df0-8b21-3ccf24e3d50e
This commit is contained in:
parent
10d4ec62e0
commit
75e1702659
2
cJSON.c
2
cJSON.c
@ -311,7 +311,7 @@ static char *print_object(cJSON *item,int depth)
|
|||||||
char *out,*ptr,*ret,*str;int len=7,i;
|
char *out,*ptr,*ret,*str;int len=7,i;
|
||||||
cJSON *child=item->child;
|
cJSON *child=item->child;
|
||||||
|
|
||||||
depth++;out=(char*)malloc(len+depth);*out='{';
|
depth++;len+=depth;out=(char*)malloc(len);*out='{';
|
||||||
ptr=out+1;*ptr++='\n';*ptr=0;
|
ptr=out+1;*ptr++='\n';*ptr=0;
|
||||||
while (child)
|
while (child)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user