cJSON_Print创建的对象需要使用cJSON_free释放

Signed-off-by: liduo <liduo29@huawei.com>
This commit is contained in:
liduo
2025-12-10 11:44:25 +08:00
parent d1053a7d1f
commit c8ee126fa8
2 changed files with 4 additions and 3 deletions
+2 -1
View File
@@ -295,7 +295,8 @@ string CompressionParser::ParseJsonStr(const cJSON *node)
return "";
}
string res(jsonString);
free(jsonString);
cJSON_free(jsonString);
jsonString = nullptr;
return res;
}
+2 -2
View File
@@ -118,8 +118,8 @@ bool ResourceUtil::SaveToJsonFile(const string &path, const cJSON *root)
}
char *jsonString = cJSON_Print(root);
out << jsonString;
free(jsonString);
cJSON_free(jsonString);
jsonString = nullptr;
out.close();
return true;
}