在 cJSON_ReplaceItemInObject 中出现了使用后释放问题,当键是项的自身名称时
作者: Fengxiaoxx创建于 2026年9月17日更新于 2026年9月17日
static cJSON_bool replace_item_in_object(cJSON *object, const char *string, cJSON *replacement, cJSON_bool case_sensitive) {
char *new_key = NULL;
if ((replacement == NULL) || (string == NULL)) { return false; }
/* copy the key first, string may point to replacement->string */
new_key = (char*)cJSON_strdup((const unsigned char*)string, &global_hooks);
if (new_key == NULL)
{
return false;}
/* replace the name in the replacement */ if
内容来源: DaveGamble/cJSON