mirror of
https://github.com/openharmony/developtools_syscap_codec.git
synced 2026-08-27 02:11:19 -04:00
消除src/syscap_tool.c代码安全告警
优化异常条件判断语句,消除src/syscap_tool.c代码安全告警 Signed-off-by: tongkai0808fh <tongkai5@huawei.com>
This commit is contained in:
+9
-1
@@ -474,13 +474,20 @@ int32_t EncodeRpcidscToString(char *inputFile, char *outDirPath)
|
||||
// trans to string format
|
||||
freeAfterEncodeRpcidscInfo.sysCapDefine = CreateWholeSyscapJsonObj();
|
||||
sysCapArray = cJSON_GetObjectItem(freeAfterEncodeRpcidscInfo.rpcidRoot, "syscap");
|
||||
if (sysCapArray == NULL || !cJSON_IsArray(sysCapArray)) {
|
||||
if (sysCapArray == NULL) {
|
||||
PRINT_ERR("syscap array is null. Input file: %s\n", inputFile);
|
||||
return FreeAfterEncodeRpcidsc(freeAfterEncodeRpcidscInfo, FREE_WHOLE_SYSCAP_AFTER_RPCIDSC, ret);
|
||||
}
|
||||
if (!cJSON_IsArray(sysCapArray)) {
|
||||
PRINT_ERR("Get syscap failed. Input file: %s\n", inputFile);
|
||||
sysCapArray = NULL;
|
||||
return FreeAfterEncodeRpcidsc(freeAfterEncodeRpcidscInfo, FREE_WHOLE_SYSCAP_AFTER_RPCIDSC, ret);
|
||||
}
|
||||
sysCapArraySize = cJSON_GetArraySize(sysCapArray);
|
||||
if (sysCapArraySize < 0) {
|
||||
PRINT_ERR("Get syscap size failed. Input file: %s\n", inputFile);
|
||||
sysCapArray = NULL;
|
||||
sysCapArraySize = NULL;
|
||||
return FreeAfterEncodeRpcidsc(freeAfterEncodeRpcidscInfo, FREE_WHOLE_SYSCAP_AFTER_RPCIDSC, ret);
|
||||
}
|
||||
// malloc for save os syscap index
|
||||
@@ -492,6 +499,7 @@ int32_t EncodeRpcidscToString(char *inputFile, char *outDirPath)
|
||||
|
||||
ret = OutputSetMemAndPrintToFile(freeAfterEncodeRpcidscInfo, sysCapArraySize, sysCapArray, outDirPath);
|
||||
if (freeAfterEncodeRpcidscInfo.flag == 1) {
|
||||
freeAfterEncodeRpcidscInfo.osSysCapIndex = NULL;
|
||||
return FreeAfterEncodeRpcidsc(freeAfterEncodeRpcidscInfo, freeAfterEncodeRpcidscInfo.type, ret);
|
||||
}
|
||||
return FreeAfterEncodeRpcidsc(freeAfterEncodeRpcidscInfo, FREE_OUTBUFFER_AFTER_RPCIDSC, ret);
|
||||
|
||||
Reference in New Issue
Block a user