Fixed defects detected by static analysis tool 55/172355/2
authorJi-hoon Lee <dalton.lee@samsung.com>
Tue, 13 Mar 2018 10:07:35 +0000 (19:07 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Tue, 13 Mar 2018 10:45:04 +0000 (10:45 +0000)
Change-Id: I10d2270d7ae55587607aad4e21463a08bfb78c90

src/SttManager.cpp
src/ise-stt-mode.cpp
src/ise.cpp

index 50e3135..0a74373 100644 (file)
@@ -61,12 +61,12 @@ SttManager::SttManager(ISttFeedback& feedback)
          * Create stt handle.
          *
          */
-        int ret = stt_create(&handle);
+        int ret = static_cast<int>(stt_create(&handle));
 
         if (ret != STT_ERROR_NONE)
             throw SttException(ret, ErrorString((stt_error_e)ret));
 
-        ret = sound_manager_create_stream_information(SOUND_STREAM_TYPE_VOICE_RECOGNITION, player_focus_state_cb, NULL, &g_stream_info_h);
+        ret = static_cast<int>(sound_manager_create_stream_information(SOUND_STREAM_TYPE_VOICE_RECOGNITION, player_focus_state_cb, NULL, &g_stream_info_h));
         if (SOUND_MANAGER_ERROR_NONE != ret) {
             LOGW("Fail to create stream info. ret : %d", ret);
         }
index 9294e3d..a094ccd 100644 (file)
@@ -55,7 +55,7 @@ void voice_result_string_flush()
 {
     if (my_voicedata && my_voicedata->partial_result) {
         SECURE_LOGD("***** result_text : %s *******", my_voicedata->partial_result);
-        const int BUF_LEN = strlen(my_voicedata->partial_result) + 1;
+        const int BUF_LEN = 256;
         char retStr[BUF_LEN] = {0};
         snprintf(retStr, BUF_LEN, "%s", my_voicedata->partial_result);
         ise_send_string(retStr);
@@ -232,9 +232,13 @@ static Eina_Bool _mic_button_enable_cb(void *data)
 
 void init_customizing_theme(void)
 {
-    std::string stt_edj_path = app_get_resource_path();
-    stt_edj_path = stt_edj_path + STT_EDJ_FILE;
-    elm_theme_extension_add(NULL, stt_edj_path.c_str());
+    char *resource_path = app_get_resource_path();
+    if (resource_path) {
+        std::string stt_edj_path = resource_path;
+        stt_edj_path = stt_edj_path + STT_EDJ_FILE;
+        elm_theme_extension_add(NULL, stt_edj_path.c_str());
+        free(resource_path);
+    }
 }
 
 bool _app_stt_initialize(VoiceData *voice_data)
@@ -629,7 +633,13 @@ Evas_Object *create_fullview(Evas_Object *win, VoiceData *r_voicedata)
 
     voicedata->layout_main = layout_main;
 
-    std::string edj_path = app_get_resource_path();
+    std::string edj_path;
+    char *resource_path = app_get_resource_path();
+    if (resource_path) {
+        edj_path = resource_path;
+        free(resource_path);
+        resource_path = NULL;
+    }
     edj_path = edj_path + STT_EDJ_FILE;
     LOGD("edj_path = %s", edj_path.c_str());
 
index b548dc6..c696ccf 100644 (file)
@@ -255,7 +255,7 @@ static void update_candidate_table()
 static void _input_smartreply_notify_cb(void *user_data)
 {
     g_smartreply_strings.clear();
-    char *candidate;
+    char *candidate = NULL;
 
     if (input_smartreply_is_enabled()) {
         /* Append newly added smartreply list */
@@ -272,6 +272,8 @@ static void _input_smartreply_notify_cb(void *user_data)
                 if (candidate) {
                     g_smartreply_strings.push_back(string(candidate));
                     g_smartreply_size++;
+                    free(candidate);
+                    candidate = NULL;
                 }
             }
             g_ic_smartreply = g_ic;
@@ -2587,7 +2589,7 @@ static void ime_app_layout_set_cb(Ecore_IMF_Input_Panel_Layout layout, void *use
 {
     LOGD("layout=%d\n", layout);
     /* Check if the layoutIdx is in the valid range */
-    if ((ISE_LAYOUT)layout < ISE_LAYOUT_STYLE_MAX) {
+    if (static_cast<int>(layout) < static_cast<int>(ISE_LAYOUT_STYLE_MAX)) {
         if (g_keyboard_state.layout != layout) {
             g_keyboard_state.need_reset = TRUE;
         }