[Bug] Fix memory leak risk in syscap_tool

IssueNo: https://gitee.com/openharmony/developtools_syscap_codec/issues/IAGOX4

Signed-off-by: luming <luming29@huawei.com>
This commit is contained in:
luming
2024-07-31 14:54:35 +08:00
parent a8dd3207a1
commit cd274f06b5
2 changed files with 10 additions and 1 deletions
+6 -1
View File
@@ -112,7 +112,12 @@ int32_t SetPriSyscap(PCIDMain *pcidBuffer, cJSON *jsonPriSyscapObj,
PRINT_ERR("get jsonArrayItem failed!");
return -1;
}
priSyscapStr = strchr(jsonArrayItem->valuestring, '.') + 1;
priSyscapStr = strchr(jsonArrayItem->valuestring, '.');
if (priSyscapStr == NULL) {
PRINT_ERR("get priSyscapStr failed!");
return -1;
}
priSyscapStr += 1;
errno_t nRet = strcat_s(priSyscapHead, allPriSyscapStrLen + 1, priSyscapStr);
nRet += strcat_s(priSyscapHead, allPriSyscapStrLen + 1, ",");
if (nRet != EOK) {
+4
View File
@@ -78,6 +78,10 @@ int main(int argc, char **argv)
g_customerfileinfo.pcidfile = NULL;
g_customerfileinfo.rpcidfile = NULL;
char *outputpath = getcwd(curpath, sizeof(curpath));
if (outputpath == NULL) {
PRINT_ERR("Get outputpath failed.\n");
return -1;
}
while (1) {
int32_t flag = getopt_long(argc, argv, "hvRPC:edsi:o:", g_longOptions, &optIndex);