From cfa0b522db19cfbf089ae72f1e915221a3d7bfb8 Mon Sep 17 00:00:00 2001 From: lsq Date: Tue, 20 Sep 2022 22:42:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=88=A4=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lsq Change-Id: I5084cc8ff0835cf12ca889c81a06b78dd478f3ad --- interfaces/innerkits/nativetoken/src/nativetoken_json_oper.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/interfaces/innerkits/nativetoken/src/nativetoken_json_oper.c b/interfaces/innerkits/nativetoken/src/nativetoken_json_oper.c index 2f7247250..38ad52b81 100644 --- a/interfaces/innerkits/nativetoken/src/nativetoken_json_oper.c +++ b/interfaces/innerkits/nativetoken/src/nativetoken_json_oper.c @@ -31,7 +31,8 @@ void FreeStrArray(char **arr, int32_t num) uint32_t GetProcessNameFromJson(cJSON *cjsonItem, NativeTokenList *tokenNode) { cJSON *processNameJson = cJSON_GetObjectItem(cjsonItem, PROCESS_KEY_NAME); - if (!cJSON_IsString(processNameJson) || (strlen(processNameJson->valuestring) > MAX_PROCESS_NAME_LEN)) { + if (!cJSON_IsString(processNameJson) || (processNameJson->valuestring == NULL) || + (strlen(processNameJson->valuestring) > MAX_PROCESS_NAME_LEN)) { AT_LOG_ERROR("[ATLIB-%s]:processNameJson is invalid.", __func__); return ATRET_FAILED; } @@ -283,7 +284,7 @@ uint32_t UpdateGoalItemFromRecord(const NativeTokenList *tokenNode, cJSON *recor return ATRET_FAILED; } cJSON *processNameJson = cJSON_GetObjectItem(cjsonItem, PROCESS_KEY_NAME); - if (processNameJson == NULL) { + if ((processNameJson == NULL) || (processNameJson->valuestring == NULL)) { AT_LOG_ERROR("[ATLIB-%s]:processNameJson is null.", __func__); return ATRET_FAILED; } -- Gitee