mirror of
https://github.com/openharmony/developtools_global_resource_tool.git
synced 2026-07-18 00:54:31 -04:00
cJSON_Print创建的对象需要使用cJSON_free释放
Signed-off-by: liduo <liduo29@huawei.com>
This commit is contained in:
@@ -295,7 +295,8 @@ string CompressionParser::ParseJsonStr(const cJSON *node)
|
||||
return "";
|
||||
}
|
||||
string res(jsonString);
|
||||
free(jsonString);
|
||||
cJSON_free(jsonString);
|
||||
jsonString = nullptr;
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user