Fix issue detected by static analysis tool 24/172324/5
authorInHong Han <inhong1.han@samsung.com>
Tue, 13 Mar 2018 07:51:57 +0000 (16:51 +0900)
committerInHong Han <inhong1.han@samsung.com>
Tue, 13 Mar 2018 11:17:18 +0000 (20:17 +0900)
Change-Id: Iee5916db218695afed44c503597b2371e0e1a384

ism/extras/efl_panel/isf_panel_efl.cpp
ism/modules/panelagent/ecoresocket/ecore_socket_panel_agent_module.cpp
ism/modules/panelagent/wayland/wayland_panel_agent_module.cpp
ism/src/isf_message_queue.h
ism/src/isf_remote_control.cpp

index 0dc70d8..14067b3 100644 (file)
@@ -153,9 +153,9 @@ typedef enum _WINDOW_STATE {
 
 typedef struct NotiData
 {
-    const char* title;
-    const char* content;
-    const char* icon;
+    String title;
+    String content;
+    String icon;
     String launch_app;
     int noti_id;
 } NotificationData;
@@ -486,7 +486,7 @@ static double             _system_scale                     = 1.0;
 
 #ifdef HAVE_NOTIFICATION
 static NotificationData hwkbd_module_noti                   = {"Input detected from hardware keyboard", "Tap to use virtual keyboard", ISF_KEYBOARD_ICON_FILE, "", 0};
-static NotificationData ise_selector_module_noti            = {"Select input method", NULL, "", "", 0};
+static NotificationData ise_selector_module_noti            = {"Select input method", "", "", "", 0};
 #endif
 
 #if ISF_BUILD_CANDIDATE_UI
@@ -700,15 +700,9 @@ static void create_notification (NotificationData *noti_data)
     if (notification != NULL) {
         notification_set_pkgname (notification, "isf-panel-efl");
         notification_set_layout (notification, NOTIFICATION_LY_ONGOING_EVENT);
-        if (noti_data->icon)
-            notification_set_image (notification, NOTIFICATION_IMAGE_TYPE_ICON, noti_data->icon);
-
-        if (noti_data->title)
-            notification_set_text (notification, NOTIFICATION_TEXT_TYPE_TITLE, _(noti_data->title), NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
-
-        if (noti_data->content)
-            notification_set_text (notification, NOTIFICATION_TEXT_TYPE_CONTENT, _(noti_data->content), NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
-
+        notification_set_image (notification, NOTIFICATION_IMAGE_TYPE_ICON, noti_data->icon.c_str());
+        notification_set_text (notification, NOTIFICATION_TEXT_TYPE_TITLE, _(noti_data->title.c_str()), NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+        notification_set_text (notification, NOTIFICATION_TEXT_TYPE_CONTENT, _(noti_data->content.c_str ()), NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
         notification_set_display_applist (notification, NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY);
 
         app_control_h service = NULL;
@@ -1913,7 +1907,7 @@ int get_ime_app_list_cb (const pkgmgrinfo_appinfo_h handle, void *user_data)
     }
     else {
         ime_db.mode = TOOLBAR_HELPER_MODE;
-        if (ime_db.pkgtype.compare ("rpm") == 0) //1 Inhouse Helper ISE(IME)
+        if (ime_db.pkgtype.compare ("rpm") == 0 && path) //1 Inhouse Helper ISE(IME)
         {
             if (_TV)
                 ime_db.options = SCIM_HELPER_STAND_ALONE | SCIM_HELPER_NEED_SCREEN_INFO | SCIM_HELPER_AUTO_RESTART | ISM_HELPER_PROCESS_KEYBOARD_KEYEVENT;
@@ -6974,8 +6968,8 @@ static void show_ime_selector_notification ()
 
     LOGD("IME selector icon path : %s", noti_icon_path.c_str ());
 
-    ise_selector_module_noti.icon = noti_icon_path.c_str ();
-    ise_selector_module_noti.content = ise_name.c_str ();
+    ise_selector_module_noti.icon = noti_icon_path;
+    ise_selector_module_noti.content = ise_name;
 
     /* Find IME Selector appid for notification */
     if (ime_selector_app.length () < 1) {
index b6e9d00..c4e856d 100644 (file)
@@ -1936,12 +1936,12 @@ private:
                         trans.put_data(ret);
                         trans.write_to_socket(client_socket);
 
-                        if (data != NULL)
-                            delete[] data;
-
                         if (ret)
                             m_info_manager->show_ise_panel(client_id, client, context, data, len);
 
+                        if (data != NULL)
+                            delete[] data;
+
                         continue;
                     } else if (cmd == ISM_TRANS_CMD_HIDE_ISE_PANEL) {
                         uint32 client;
@@ -2717,6 +2717,9 @@ private:
                     } else {
                         LOGW("wrong format of transaction");
                     }
+
+                    if (data != NULL)
+                        delete [] data;
                 } else if (cmd == ISM_TRANS_CMD_GET_KEYBOARD_ISE_LIST) {
                     String uuid;
 
index a91fcaf..c24902a 100644 (file)
@@ -490,7 +490,7 @@ _wsc_im_ctx_mime_type (void *data, struct wl_input_method_context *im_ctx, const
     if (!wsc_ctx) return;
 
     if (wsc_ctx->impl) {
-        wsc_ctx->impl->mime_type = strdup (mime_type);
+        wsc_ctx->impl->mime_type = String (mime_type);
     }
 
     isf_wsc_context_input_panel_mime_type_accept_set (wsc_ctx, mime_type);
@@ -1944,7 +1944,7 @@ wsc_send_preedit_style (WSCContextISF* wsc_ctx)
             }
         }
     } else {
-        if (!wsc_ctx->impl->preedit_attrlist.empty ())
+        if (wsc_ctx->impl && !wsc_ctx->impl->preedit_attrlist.empty ())
             wsc_ctx->impl->preedit_attrlist.clear ();
     }
 }
index 018c9cc..16d4e46 100644 (file)
@@ -1142,6 +1142,9 @@ public:
                         message->get_command_ref() = cmd;
                         if (transaction.get_data(message->get_type_ref())) {
                             m_list_messages.push_back(message);
+                        } else {
+                            LOGW("wrong format of transaction");
+                            dealloc_message<MessageItemSetReturnKeyType>(message);
                         }
                     }
                     break;
index d688b6a..ee2d6a2 100644 (file)
@@ -19,22 +19,41 @@ using namespace scim;
 static bool focus_flag;
 
 struct _remote_control_client {
-    RemoteInputClient remote_client;
-    GIOChannel *remote_client_iochannel = NULL;
+    RemoteInputClient *remote_client;
+    GIOChannel *remote_client_iochannel;
     guint remote_client_iochannel_read;
     guint remote_client_iochannel_err;
     guint remote_client_iochannel_hup;
     int remote_client_id;
-    remote_control_focus_in_cb focus_in_cb = NULL;
+    remote_control_focus_in_cb focus_in_cb;
     void* focus_in_cb_user_data;
-    remote_control_focus_out_cb focus_out_cb = NULL;
+    remote_control_focus_out_cb focus_out_cb;
     void* focus_out_cb_user_data;
-    remote_control_entry_metadata_cb metadata_cb = NULL;
+    remote_control_entry_metadata_cb metadata_cb;
     void* metadata_cb_user_data;
-    remote_control_text_updated_cb text_updated_cb = NULL;
+    remote_control_text_updated_cb text_updated_cb;
     void* text_updated_cb_user_data;
-    remote_control_input_resource_changed_cb input_resource_changed_cb = NULL;
+    remote_control_input_resource_changed_cb input_resource_changed_cb;
     void* input_resource_changed_cb_user_data;
+
+    _remote_control_client() : remote_client(NULL),
+                               remote_client_iochannel(NULL),
+                               remote_client_iochannel_read(0),
+                               remote_client_iochannel_err(0),
+                               remote_client_iochannel_hup(0),
+                               remote_client_id(0),
+                               focus_in_cb(NULL),
+                               focus_in_cb_user_data(NULL),
+                               focus_out_cb(NULL),
+                               focus_out_cb_user_data(NULL),
+                               metadata_cb(NULL),
+                               metadata_cb_user_data(NULL),
+                               text_updated_cb(NULL),
+                               text_updated_cb_user_data(NULL),
+                               input_resource_changed_cb(NULL),
+                               input_resource_changed_cb_user_data(NULL)
+    {
+    }
 };
 
 static gboolean
@@ -42,8 +61,8 @@ remote_handler(GIOChannel *source, GIOCondition condition, gpointer user_data)
 {
     if (condition == G_IO_IN) {
         remote_control_client *client = static_cast<remote_control_client*>(user_data);
-        if (client->remote_client.has_pending_event()) {
-            switch (client->remote_client.recv_callback_message()) {
+        if (client->remote_client->has_pending_event()) {
+            switch (client->remote_client->recv_callback_message()) {
                 case REMOTE_CONTROL_CALLBACK_FOCUS_IN:
                 {
                     LOGD ("REMOTE_CONTROL_CALLBACK_FOCUS_IN");
@@ -68,7 +87,7 @@ remote_handler(GIOChannel *source, GIOCondition condition, gpointer user_data)
                         remote_control_entry_metadata_s *data = new remote_control_entry_metadata_s;
                         int hint = 0, layout = 0, variation = 0, autocapital_type = 0, return_key_disabled = 0;
 
-                        client->remote_client.get_entry_metadata (&hint, &layout, &variation, &autocapital_type, &return_key_disabled);
+                        client->remote_client->get_entry_metadata (&hint, &layout, &variation, &autocapital_type, &return_key_disabled);
                         data->hint = static_cast<Ecore_IMF_Input_Hints> (hint);
                         data->layout = static_cast<Ecore_IMF_Input_Panel_Layout> (layout);
                         data->variation = variation;
@@ -90,7 +109,7 @@ remote_handler(GIOChannel *source, GIOCondition condition, gpointer user_data)
                         String surrounding_text;
                         int cursor = -1;
 
-                        client->remote_client.get_surrounding_text (surrounding_text, &cursor);
+                        client->remote_client->get_surrounding_text (surrounding_text, &cursor);
                         SECURE_LOGD ("REMOTE_CONTROL_CALLBACK_TEXT_UPDATED: %d \"%s\"", cursor, surrounding_text.c_str ());
 
                         if (client->text_updated_cb)
@@ -103,7 +122,7 @@ remote_handler(GIOChannel *source, GIOCondition condition, gpointer user_data)
                     if (focus_flag) {
                         int resource = 0;
 
-                        client->remote_client.get_input_resource (&resource);
+                        client->remote_client->get_input_resource (&resource);
                         LOGD ("REMOTE_CONTROL_CALLBACK_INPUT_RESOURCE: %s", (resource ? "REMOTE" : "LOCAL"));
 
                         if (client->input_resource_changed_cb)
@@ -136,20 +155,25 @@ EXAPI remote_control_client * remote_control_connect(void)
     focus_flag = false;
 
     if (client) {
-        RemoteInputClient *remote_client = new RemoteInputClient;
-        client->remote_client = *remote_client;
-        if (!client->remote_client.open_connection()) {
+        client->remote_client = new RemoteInputClient;
+
+        if (!client->remote_client) {
+            LOGE ("Failed to generate remote_client");
+            goto cleanup;
+        }
+
+        if (!client->remote_client->open_connection()) {
             LOGE ("REMOTE_CONTROL_REPLY_TIMEOUT");
             goto cleanup;
         }
 
-        remote_control_error_e error_e = (remote_control_error_e)client->remote_client.check_privilege();
+        remote_control_error_e error_e = (remote_control_error_e)client->remote_client->check_privilege();
         if (error_e) {
             LOGE ("REMOTE_CONTROL_PERMISSION_DENIED");
             goto cleanup;
         }
 
-        client->remote_client_id = client->remote_client.get_panel2remote_connection_number();
+        client->remote_client_id = client->remote_client->get_panel2remote_connection_number();
 
         if (client->remote_client_id >= 0) {
             client->remote_client_iochannel = g_io_channel_unix_new(client->remote_client_id);
@@ -177,6 +201,9 @@ EXAPI remote_control_client * remote_control_connect(void)
     return client;
 
 cleanup:
+    if (client->remote_client)
+        delete client->remote_client;
+
     if (client)
         delete client;
 
@@ -190,7 +217,7 @@ EXAPI int remote_control_disconnect(remote_control_client *client)
         return REMOTE_CONTROL_INVALID_PARAMETER;
     }
 
-    remote_control_error_e error_e = (remote_control_error_e)client->remote_client.check_privilege();
+    remote_control_error_e error_e = (remote_control_error_e)client->remote_client->check_privilege();
     if (error_e) {
         LOGE ("REMOTE_CONTROL_PERMISSION_DENIED");
         return error_e;
@@ -213,9 +240,12 @@ EXAPI int remote_control_disconnect(remote_control_client *client)
     client->remote_client_iochannel_err = 0;
     client->remote_client_iochannel_hup = 0;
 
-    client->remote_client.close_connection();
+    client->remote_client->close_connection();
 
     LOGD ("%p", client);
+    if (client->remote_client)
+        delete client->remote_client;
+
     delete client;
     client = NULL;
 
@@ -229,7 +259,7 @@ EXAPI int remote_control_focus_in_callback_set(remote_control_client *client, re
         return REMOTE_CONTROL_INVALID_PARAMETER;
     }
 
-    remote_control_error_e error_e = (remote_control_error_e)client->remote_client.check_privilege();
+    remote_control_error_e error_e = (remote_control_error_e)client->remote_client->check_privilege();
     if (error_e) {
         LOGE ("REMOTE_CONTROL_PERMISSION_DENIED");
         return error_e;
@@ -249,7 +279,7 @@ EXAPI int remote_control_focus_in_callback_unset(remote_control_client *client)
         return REMOTE_CONTROL_INVALID_PARAMETER;
     }
 
-    remote_control_error_e error_e = (remote_control_error_e)client->remote_client.check_privilege();
+    remote_control_error_e error_e = (remote_control_error_e)client->remote_client->check_privilege();
     if (error_e) {
         LOGE ("REMOTE_CONTROL_PERMISSION_DENIED");
         return error_e;
@@ -269,7 +299,7 @@ EXAPI int remote_control_focus_out_callback_set(remote_control_client *client, r
         return REMOTE_CONTROL_INVALID_PARAMETER;
     }
 
-    remote_control_error_e error_e = (remote_control_error_e)client->remote_client.check_privilege();
+    remote_control_error_e error_e = (remote_control_error_e)client->remote_client->check_privilege();
     if (error_e) {
         LOGE ("REMOTE_CONTROL_PERMISSION_DENIED");
         return error_e;
@@ -289,7 +319,7 @@ EXAPI int remote_control_focus_out_callback_unset(remote_control_client *client)
         return REMOTE_CONTROL_INVALID_PARAMETER;
     }
 
-    remote_control_error_e error_e = (remote_control_error_e)client->remote_client.check_privilege();
+    remote_control_error_e error_e = (remote_control_error_e)client->remote_client->check_privilege();
     if (error_e) {
         LOGE ("REMOTE_CONTROL_PERMISSION_DENIED");
         return error_e;
@@ -309,7 +339,7 @@ EXAPI int remote_control_entry_metadata_callback_set(remote_control_client *clie
         return REMOTE_CONTROL_INVALID_PARAMETER;
     }
 
-    remote_control_error_e error_e = (remote_control_error_e)client->remote_client.check_privilege();
+    remote_control_error_e error_e = (remote_control_error_e)client->remote_client->check_privilege();
     if (error_e) {
         LOGE ("REMOTE_CONTROL_PERMISSION_DENIED");
         return error_e;
@@ -329,7 +359,7 @@ EXAPI int remote_control_entry_metadata_callback_unset(remote_control_client *cl
         return REMOTE_CONTROL_INVALID_PARAMETER;
     }
 
-    remote_control_error_e error_e = (remote_control_error_e)client->remote_client.check_privilege();
+    remote_control_error_e error_e = (remote_control_error_e)client->remote_client->check_privilege();
     if (error_e) {
         LOGE ("REMOTE_CONTROL_PERMISSION_DENIED");
         return error_e;
@@ -349,7 +379,7 @@ EXAPI int remote_control_text_updated_callback_set(remote_control_client *client
         return REMOTE_CONTROL_INVALID_PARAMETER;
     }
 
-    remote_control_error_e error_e = (remote_control_error_e)client->remote_client.check_privilege();
+    remote_control_error_e error_e = (remote_control_error_e)client->remote_client->check_privilege();
     if (error_e) {
         LOGE ("REMOTE_CONTROL_PERMISSION_DENIED");
         return error_e;
@@ -369,7 +399,7 @@ EXAPI int remote_control_text_updated_callback_unset(remote_control_client *clie
         return REMOTE_CONTROL_INVALID_PARAMETER;
     }
 
-    remote_control_error_e error_e = (remote_control_error_e)client->remote_client.check_privilege();
+    remote_control_error_e error_e = (remote_control_error_e)client->remote_client->check_privilege();
     if (error_e) {
         LOGE ("REMOTE_CONTROL_PERMISSION_DENIED");
         return error_e;
@@ -389,7 +419,7 @@ EXAPI int remote_control_input_resource_changed_callback_set(remote_control_clie
         return REMOTE_CONTROL_INVALID_PARAMETER;
     }
 
-    remote_control_error_e error_e = (remote_control_error_e)client->remote_client.check_privilege();
+    remote_control_error_e error_e = (remote_control_error_e)client->remote_client->check_privilege();
     if (error_e) {
         LOGE ("REMOTE_CONTROL_PERMISSION_DENIED");
         return error_e;
@@ -409,7 +439,7 @@ EXAPI int remote_control_input_resource_changed_callback_unset(remote_control_cl
         return REMOTE_CONTROL_INVALID_PARAMETER;
     }
 
-    remote_control_error_e error_e = (remote_control_error_e)client->remote_client.check_privilege();
+    remote_control_error_e error_e = (remote_control_error_e)client->remote_client->check_privilege();
     if (error_e) {
         LOGE ("REMOTE_CONTROL_PERMISSION_DENIED");
         return error_e;
@@ -429,7 +459,7 @@ EXAPI int remote_control_send_key_event(remote_control_client *client, remote_co
         return REMOTE_CONTROL_INVALID_PARAMETER;
     }
 
-    remote_control_error_e error_e = (remote_control_error_e)client->remote_client.check_privilege();
+    remote_control_error_e error_e = (remote_control_error_e)client->remote_client->check_privilege();
     if (error_e) {
         LOGE ("REMOTE_CONTROL_PERMISSION_DENIED");
         return error_e;
@@ -440,7 +470,7 @@ EXAPI int remote_control_send_key_event(remote_control_client *client, remote_co
     String command = String ("|plain|send_key_event|") + String (key_str) + String ("|");
 
     if (focus_flag) {
-        error_e = (remote_control_error_e)client->remote_client.send_remote_input_message(command.c_str ());
+        error_e = (remote_control_error_e)client->remote_client->send_remote_input_message(command.c_str ());
 
         if (!error_e)
             SECURE_LOGD ("%p, key=%d", client, key);
@@ -459,7 +489,7 @@ EXAPI int remote_control_send_commit_string(remote_control_client *client, const
         return REMOTE_CONTROL_INVALID_PARAMETER;
     }
 
-    remote_control_error_e error_e = (remote_control_error_e)client->remote_client.check_privilege();
+    remote_control_error_e error_e = (remote_control_error_e)client->remote_client->check_privilege();
     if (error_e) {
         LOGE ("REMOTE_CONTROL_PERMISSION_DENIED");
         return error_e;
@@ -468,7 +498,7 @@ EXAPI int remote_control_send_commit_string(remote_control_client *client, const
     String command = String ("|plain|commit_string|") + String (text) + String ("|");
 
     if (focus_flag) {
-        error_e = (remote_control_error_e)client->remote_client.send_remote_input_message(command.c_str ());
+        error_e = (remote_control_error_e)client->remote_client->send_remote_input_message(command.c_str ());
 
         if (!error_e)
             SECURE_LOGD ("%p, \"%s\"", client, text);
@@ -487,7 +517,7 @@ EXAPI int remote_control_update_preedit_string(remote_control_client *client, co
         return REMOTE_CONTROL_INVALID_PARAMETER;
     }
 
-    remote_control_error_e error_e = (remote_control_error_e)client->remote_client.check_privilege();
+    remote_control_error_e error_e = (remote_control_error_e)client->remote_client->check_privilege();
     if (error_e) {
         LOGE ("REMOTE_CONTROL_PERMISSION_DENIED");
         return error_e;
@@ -498,7 +528,7 @@ EXAPI int remote_control_update_preedit_string(remote_control_client *client, co
     String command = String ("|plain|update_preedit_string|") + String (text) + String ("|") + String (cursor_position) + String ("|");
 
     if (focus_flag) {
-        error_e = (remote_control_error_e)client->remote_client.send_remote_input_message(command.c_str ());
+        error_e = (remote_control_error_e)client->remote_client->send_remote_input_message(command.c_str ());
 
         if (!error_e)
             SECURE_LOGD ("%p, %d, \"%s\"", client, cursor_pos, text);
@@ -517,14 +547,14 @@ EXAPI int remote_control_delete_surrounding_text(remote_control_client *client,
         return REMOTE_CONTROL_INVALID_PARAMETER;
     }
 
-    remote_control_error_e error_e = (remote_control_error_e)client->remote_client.check_privilege();
+    remote_control_error_e error_e = (remote_control_error_e)client->remote_client->check_privilege();
     if (error_e) {
         LOGE ("REMOTE_CONTROL_PERMISSION_DENIED");
         return error_e;
     }
 
     if (focus_flag) {
-        error_e = (remote_control_error_e)client->remote_client.delete_surrounding_text(offset, len);
+        error_e = (remote_control_error_e)client->remote_client->delete_surrounding_text(offset, len);
 
         if (!error_e)
             LOGD ("%p, (%d, %d)", client, offset, len);
@@ -535,4 +565,3 @@ EXAPI int remote_control_delete_surrounding_text(remote_control_client *client,
     LOGE ("REMOTE_CONTROL_INVALID_OPERATION");
     return REMOTE_CONTROL_INVALID_OPERATION;
 }
-