diff --git a/src/create_pcid.c b/src/create_pcid.c index c2c429b1d5b3acc488092e8291e9334a052a3e4b..b80a1e34cbab6593c295db7c3dbedbf6a91be948 100644 --- a/src/create_pcid.c +++ b/src/create_pcid.c @@ -448,7 +448,7 @@ static int32_t FreeAfterDecodePCID(struct FreeDecodePcidJsonInfo freePcidJsonInf { switch (type) { case FREE_DECODE_PCID_CONVERT_OUT: - free(freePcidJsonInfo.strJson); + cJSON_Delete(freePcidJsonInfo.strJson); cJSON_Delete(freePcidJsonInfo.jsonRootObj); FreeContextBuffer(freePcidJsonInfo.contextBuffer); break; @@ -524,6 +524,8 @@ int32_t DecodePCID(char *inputFile, char *outDirPath) return FreeAfterDecodePCID(freePcidJsonInfo, FREE_DECODE_PCID_ROOT_OUT, ret); } + freePcidJsonInfo.sysCapObj = NULL; // avoid being released repeatedly. + freePcidJsonInfo.strJson = cJSON_Print(freePcidJsonInfo.jsonRootObj); const char outputFileName[] = "pcid.json"; diff --git a/src/syscap_tool.c b/src/syscap_tool.c index 93d33448ecb382319c57cbddecd869a5e5d6f292..e5953d66d05caf693c1ba7e08ac430aab13ea647 100644 --- a/src/syscap_tool.c +++ b/src/syscap_tool.c @@ -285,8 +285,10 @@ int32_t RPCIDDecode(char *inputFile, char *outputPath) ret = ConvertedContextSaveAsFile(outputPath, "rpcid.json", convertedBuffer, strlen(convertedBuffer)); if (ret != 0) { PRINT_ERR("ConvertedContextSaveAsFile failed, outputPath:%s, filename:rpcid.json\n", outputPath); + cJSON_Delete(convertedBuffer); goto FREE_RPCID_ROOT; } + cJSON_Delete(convertedBuffer); FREE_RPCID_ROOT: cJSON_Delete(rpcidRoot);