diff --git a/cJSON.c b/cJSON.c index 4929fd3dab1c4689dbd665312ebe45bdd8419b1f..ef7e6fe88c97109623253e4123e46e4cf88fff53 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);