mirror of
https://github.com/DaveGamble/cJSON
synced 2025-01-13 02:26:44 +00:00
fix bug: 2885206, whereby memory would leak in print_object if print_value failed.
git-svn-id: http://svn.code.sf.net/p/cjson/code@9 e3330c51-1366-4df0-8b21-3ccf24e3d50e
This commit is contained in:
parent
75e1702659
commit
c052999a71
2
cJSON.c
2
cJSON.c
@ -318,7 +318,7 @@ static char *print_object(cJSON *item,int depth)
|
|||||||
str=print_string_ptr(child->string);
|
str=print_string_ptr(child->string);
|
||||||
if (!str) {free(out);return 0;}
|
if (!str) {free(out);return 0;}
|
||||||
ret=print_value(child,depth);
|
ret=print_value(child,depth);
|
||||||
if (!ret) {free(out);return 0;} // Check for failure!
|
if (!ret) {free(str);free(out);return 0;} // Check for failure!
|
||||||
len+=strlen(ret)+strlen(str)+4+depth;
|
len+=strlen(ret)+strlen(str)+4+depth;
|
||||||
out=(char*)realloc(out,len);
|
out=(char*)realloc(out,len);
|
||||||
ptr=out+strlen(out);
|
ptr=out+strlen(out);
|
||||||
|
Loading…
Reference in New Issue
Block a user