浏览代码

print_object was calling free() rather than cJSON_free() under failure conditions!

git-svn-id: http://svn.code.sf.net/p/cjson/code@36 e3330c51-1366-4df0-8b21-3ccf24e3d50e
Dave Gamble 14 年之前
父节点
当前提交
b5d2db4d9a
共有 1 个文件被更改,包括 2 次插入2 次删除
  1. 2 2
      cJSON.c

+ 2 - 2
cJSON.c

@@ -428,8 +428,8 @@ static char *print_object(cJSON *item,int depth,int fmt)
 	/* Handle failure */
 	/* Handle failure */
 	if (fail)
 	if (fail)
 	{
 	{
-		for (i=0;i<numentries;i++) {if (names[i]) free(names[i]);if (entries[i]) free(entries[i]);}
-		free(names);free(entries);
+		for (i=0;i<numentries;i++) {if (names[i]) cJSON_free(names[i]);if (entries[i]) cJSON_free(entries[i]);}
+		cJSON_free(names);cJSON_free(entries);
 		return 0;
 		return 0;
 	}
 	}