diff --git a/src/create_pcid.c b/src/create_pcid.c index c2c429b1d5b3acc488092e8291e9334a052a3e4b..811081d6dce434dc009aefff18cd05c6f1165612 100644 --- a/src/create_pcid.c +++ b/src/create_pcid.c @@ -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);