From ae2e2b12b1f37e003865a701dca76ed41f476dc8 Mon Sep 17 00:00:00 2001 From: "sungwook79.park" Date: Mon, 17 Jul 2017 16:29:19 +0900 Subject: [PATCH] Fix issues that detected by static analysis tool Change-Id: I7ca5cb4bd3f4544a67ef841eeeb0dfa5d98df343 Signed-off-by: sungwook79.park --- src/ise-stt-mode.cpp | 8 ++++---- src/ise-stt-option.cpp | 19 +++++++------------ 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/src/ise-stt-mode.cpp b/src/ise-stt-mode.cpp index 36a3685..579a769 100644 --- a/src/ise-stt-mode.cpp +++ b/src/ise-stt-mode.cpp @@ -48,10 +48,10 @@ void voice_result_string_flush() { if (my_voicedata && my_voicedata->partial_result) { LOGD("***** result_text : %s *******", my_voicedata->partial_result); - char *retStr = (char *)calloc(strlen(my_voicedata->partial_result) + 1, sizeof(char)); - strncpy(retStr, my_voicedata->partial_result, strlen(my_voicedata->partial_result)); + const int BUF_LEN = strlen(my_voicedata->partial_result) + 1; + char retStr[BUF_LEN] = {0}; + snprintf(retStr, BUF_LEN, "%s", my_voicedata->partial_result); ise_send_string(retStr); - free(retStr); } } @@ -801,7 +801,7 @@ void ise_show_stt_mode(Evas_Object *win) const int BUF_LEN = 256; static char buf[BUF_LEN] = {0}; - snprintf(buf, BUF_LEN, gettext("IDS_ST_SK_CANCEL")); + snprintf(buf, BUF_LEN, "%s", gettext("IDS_ST_SK_CANCEL")); if (g_ui) g_ui->set_string_substitution("Cancel", buf); } diff --git a/src/ise-stt-option.cpp b/src/ise-stt-option.cpp index 11bd7d5..63e6619 100644 --- a/src/ise-stt-option.cpp +++ b/src/ise-stt-option.cpp @@ -234,7 +234,8 @@ void get_stt_default_language(VoiceData *my_voicedata) static char *__get_genlist_item_label(void *data, Evas_Object *obj, const char *part) { - char text[128] = {0, }; + const int BUF_LEN = 128; + char text[BUF_LEN] = {'\0', }; if (!strcmp(part, "elm.text")) { @@ -249,10 +250,10 @@ static char *__get_genlist_item_label(void *data, Evas_Object *obj, const char * if (p) { strncpy(text, s, p-s); } else { - strncpy(text, s, strlen(s)); + snprintf(text, BUF_LEN, "%s", s); } } else { - strncpy(text, "", strlen("")); + snprintf(text, BUF_LEN, "%s", ""); } } return strdup(text); @@ -284,11 +285,10 @@ static char *__get_genlist_item_label(void *data, Evas_Object *obj, const char * if (p) { strncpy(text, p+1, strlen(s)-(p-s)-2); } else { - strncpy(text, s, strlen(s)); - text[strlen(s)] = '\0'; + snprintf(text, BUF_LEN, "%s", s); } } else { - strncpy(text, "", strlen("")); + snprintf(text, BUF_LEN, "%s", ""); } return strdup(text); } @@ -428,12 +428,7 @@ static Evas_Object *create_language_list(Evas_Object *parent) for (i = 1; i < (long)(sizeof(disp_lang_array)/sizeof(disp_lang_array[0])); i++) { char *s = (char *)disp_lang_array[i]; - - if (strchr(s, '(')){ - item = item_append(genlist, itc_1text, i, language_set_genlist_radio_cb, genlist); - } else { - item = item_append(genlist, itc_1text, i, language_set_genlist_radio_cb, genlist); - } + item = item_append(genlist, itc_1text, i, language_set_genlist_radio_cb, genlist); if (lang_val == i) { LOGD("%d item is choiced.", i); -- 2.7.4