From 7317dc3a031fb0a4824eb582e3566447a775378c Mon Sep 17 00:00:00 2001 From: "sungwook79.park" Date: Mon, 19 Aug 2024 16:00:30 +0900 Subject: [PATCH] Fix issues that detected by static analysis tools Change-Id: I343d50bfa3d17893c10c569c94121d635c490a94 Signed-off-by: sungwook79.park --- client/vc_mgr_tidl.c | 38 +++++++++++++++++++++++++++----------- client/vc_tidl.c | 6 ++++-- 2 files changed, 31 insertions(+), 13 deletions(-) diff --git a/client/vc_mgr_tidl.c b/client/vc_mgr_tidl.c index 0037087..e41e707 100644 --- a/client/vc_mgr_tidl.c +++ b/client/vc_mgr_tidl.c @@ -161,7 +161,9 @@ static void __notify_cb(void *user_data, bundle *msg) if (!strncmp(utt_text, "#NULL", strlen("#NULL") + 1)) utt_text = NULL; - vc_mgr_core_send_dialog(atoi(pid), disp_text, utt_text, (bool)atoi(continuous)); + if (pid != NULL && continuous != NULL) { + vc_mgr_core_send_dialog(atoi(pid), disp_text, utt_text, (bool)atoi(continuous)); + } } /* VCD_MANAGER_METHOD_DIALOG */ else if (0 == strncmp(VCD_MANAGER_METHOD_ERROR, method, strlen(VCD_MANAGER_METHOD_ERROR))) { @@ -178,8 +180,11 @@ static void __notify_cb(void *user_data, bundle *msg) if (NULL != err_msg && strncmp(err_msg, "#NULL", strlen("#NULL") + 1)) { temp_msg = strdup(err_msg); } - SLOG(LOG_ERROR, TAG_VCM, "@@ vc mgr Get Error message : reason(%d), daemon_pid(%d), msg(%s)", atoi(reason), atoi(daemon_pid), (temp_msg) ? temp_msg : "NULL"); - vc_mgr_core_send_error(atoi(reason), atoi(daemon_pid), temp_msg); + + if (reason != NULL && daemon_pid != NULL) { + SLOG(LOG_ERROR, TAG_VCM, "@@ vc mgr Get Error message : reason(%d), daemon_pid(%d), msg(%s)", atoi(reason), atoi(daemon_pid), (temp_msg) ? temp_msg : "NULL"); + vc_mgr_core_send_error(atoi(reason), atoi(daemon_pid), temp_msg); + } if (NULL != temp_msg) { free(temp_msg); temp_msg = NULL; @@ -196,12 +201,16 @@ static void __notify_cb(void *user_data, bundle *msg) bundle_get_str(msg, VC_BUNDLE_KEY, &key); bundle_get_str(msg, VC_BUNDLE_PRIVATE_DATA, &private_data); - int pid = atoi(tmp_pid); - SLOG(LOG_INFO, TAG_VCM, "@@ vc mgr get request set private data : pid(%d) ", pid); - if (pid > 0) { - vc_mgr_core_send_private_data_set(key, private_data); + if (tmp_pid != NULL) { + int pid = atoi(tmp_pid); + SLOG(LOG_INFO, TAG_VCM, "@@ vc mgr get request set private data : pid(%d) ", pid); + if (pid > 0) { + vc_mgr_core_send_private_data_set(key, private_data); + } else { + SLOG(LOG_ERROR, TAG_VCM, "@@ got invalid pid(%d)", pid); + } } else { - SLOG(LOG_ERROR, TAG_VCM, "@@ got invalid pid(%d)", pid); + SLOG(LOG_ERROR, TAG_VCM, "@@ pid is NULL"); } } /* VCD_MANAGER_METHOD_SET_PRIVATE_DATA */ @@ -215,7 +224,9 @@ static void __notify_cb(void *user_data, bundle *msg) bundle_get_str(msg, VC_BUNDLE_AUDIO_TYPE, &audio_type); bundle_get_str(msg, VC_BUNDLE_AUDIO_RATE, &rate); - vc_mgr_core_send_feedback_audio_format(atoi(rate), (vc_audio_channel_e)atoi(channel), (vc_audio_type_e)atoi(audio_type)); + if (rate != NULL && channel != NULL && audio_type != NULL) { + vc_mgr_core_send_feedback_audio_format(atoi(rate), (vc_audio_channel_e)atoi(channel), (vc_audio_type_e)atoi(audio_type)); + } } /* VCD_MANAGER_METHOD_FEEDBACK_AUDIO_FORMAT */ // TODO: uncomment this line after vcc done @@ -264,8 +275,13 @@ static void __send_buffer_cb(void *user_data, rpc_port_proxy_vc_mgr_proxy_array_ bundle_get_str(msg, VC_BUNDLE_EVENT, &event); rpc_port_proxy_vc_mgr_proxy_array_char_get(data_in, &buffer, &len); - vc_mgr_core_send_feedback_streaming(atoi(val), atoi(utt_id), atoi(event), buffer, len); - free(buffer); + if (val != NULL && utt_id != NULL && event != NULL) { + vc_mgr_core_send_feedback_streaming(atoi(val), atoi(utt_id), atoi(event), buffer, len); + } + if (buffer) { + free(buffer); + buffer = NULL; + } SLOG(LOG_INFO, TAG_VCM, "@@@ __send_buffer_cb DONE"); } /* VCD_MANAGER_METHOD_FEEDBACK_STREAMING */ diff --git a/client/vc_tidl.c b/client/vc_tidl.c index a9d968b..f8c03ed 100644 --- a/client/vc_tidl.c +++ b/client/vc_tidl.c @@ -245,8 +245,10 @@ static void __notify_cb(void* user_data, int pid, bundle* msg) bundle_get_str(msg, VC_BUNDLE_UTT_ID, &utt_id); bundle_get_str(msg, VC_BUNDLE_UTT_STATUS, &utt_status); - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc Get utterance status : pid(%d), utt_id(%d), utt_status(%d)", atoi(pid), atoi(utt_id), atoi(utt_status)); - __vc_cb_utterance_status(atoi(utt_id), atoi(utt_status)); + if (pid != NULL && utt_id != NULL && utt_status != NULL) { + SLOG(LOG_DEBUG, TAG_VCC, "@@ vc Get utterance status : pid(%d), utt_id(%d), utt_status(%d)", atoi(pid), atoi(utt_id), atoi(utt_status)); + __vc_cb_utterance_status(atoi(utt_id), atoi(utt_status)); + } } /* VC_MANAGER_METHOD_UTTERANCE_STATUS */ else { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid msg"); -- 2.34.1