From c052999a711a444598aaaa24b7a7f03bb86d1176 Mon Sep 17 00:00:00 2001 From: Dave Gamble Date: Thu, 29 Oct 2009 00:06:15 +0000 Subject: [PATCH] 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 --- cJSON.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cJSON.c b/cJSON.c index 4929fd3..ef7e6fe 100644 --- a/cJSON.c +++ b/cJSON.c @@ -318,7 +318,7 @@ static char *print_object(cJSON *item,int depth) str=print_string_ptr(child->string); if (!str) {free(out);return 0;} 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; out=(char*)realloc(out,len); ptr=out+strlen(out);