浏览代码

fix #106: potentially invalid free in cJSON_AddItemToObject

Max Bruckner 8 年之前
父节点
当前提交
702fd95af3
共有 1 个文件被更改,包括 1 次插入1 次删除
  1. 1 1
      cJSON.c

+ 1 - 1
cJSON.c

@@ -1771,7 +1771,7 @@ void   cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item)
     }
 
     /* free old key and set new one */
-    if (item->string)
+    if (!(item->type & cJSON_StringIsConst) && item->string)
     {
         cJSON_free(item->string);
     }