Fix issues that detected by static analysis tool 76/139076/6
authorsungwook79.park <sungwook79.park@samsung.com>
Mon, 17 Jul 2017 07:29:19 +0000 (16:29 +0900)
committersungwook79.park <sungwook79.park@samsung.com>
Tue, 18 Jul 2017 01:24:26 +0000 (10:24 +0900)
Change-Id: I7ca5cb4bd3f4544a67ef841eeeb0dfa5d98df343
Signed-off-by: sungwook79.park <sungwook79.park@samsung.com>
src/ise-stt-mode.cpp
src/ise-stt-option.cpp

index 36a3685..579a769 100644 (file)
@@ -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);
 }
index 11bd7d5..63e6619 100644 (file)
@@ -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);