提交 0d10e279 编写于 作者: M Max Bruckner

fix #55 memory leak in cJSON_ReplaceItemInObject

上级 9e310491
......@@ -1861,6 +1861,12 @@ void cJSON_ReplaceItemInObject(cJSON *object, const char *string, cJSON *newitem
}
if(c)
{
/* free the old string if not const */
if (!(newitem->type & cJSON_StringIsConst) && newitem->string)
{
cJSON_free(newitem->string);
}
newitem->string = cJSON_strdup(string);
cJSON_ReplaceItemInArray(object, i, newitem);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册