Add NULL check in wayland panel agent module 80/86180/1
authorJihoon Kim <jihoon48.kim@samsung.com>
Wed, 31 Aug 2016 02:36:21 +0000 (11:36 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Wed, 31 Aug 2016 02:36:27 +0000 (11:36 +0900)
Change-Id: I8bbbf9c917cb994eb14ea893cecacea5a032aa94
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
ism/modules/panelagent/wayland/wayland_panel_agent_module.cpp

index 3c56b1a..d694a8f 100644 (file)
@@ -2865,7 +2865,7 @@ public:
         LOGD ("client id:%d", id);
 
         int filedes[2];
-        if (pipe2(filedes,O_CLOEXEC|O_NONBLOCK) ==-1 ) {
+        if (pipe2(filedes,O_CLOEXEC | O_NONBLOCK) == -1) {
             LOGW ("create pipe failed");
             return;
         }
@@ -2873,19 +2873,24 @@ public:
         WSCContextISF* ic = find_ic (context_id);
         if (!ic) return;
 
-        wl_input_method_context_get_surrounding_text(ic->im_ctx, maxlen_before, maxlen_after, filedes[1]);
+        if (ic->im_ctx)
+            wl_input_method_context_get_surrounding_text(ic->im_ctx, maxlen_before, maxlen_after, filedes[1]);
+
         ecore_wl_flush();
         close (filedes[1]);
+
         if (ic->surrounding_text_fd_read_handler) {
             int fd = ecore_main_fd_handler_fd_get(ic->surrounding_text_fd_read_handler);
             close(fd);
             ecore_main_fd_handler_del(ic->surrounding_text_fd_read_handler);
             ic->surrounding_text_fd_read_handler = NULL;
         }
+
         if (ic->surrounding_text) {
             free (ic->surrounding_text);
             ic->surrounding_text = NULL;
         }
+
         ic->surrounding_text_fd_read_handler = ecore_main_fd_handler_add(filedes[0], ECORE_FD_READ, surrounding_text_fd_read_func, ic, NULL, NULL);
     }
 
@@ -2893,20 +2898,23 @@ public:
     socket_helper_delete_surrounding_text (int id, uint32 context_id, uint32 offset, uint32 len) {
         LOGD ("client id:%d", id);
         //panel_slot_delete_surrounding_text (context_id, offset, len);
-        wsc_context_delete_surrounding (_focused_ic, offset, len);
+        if (_focused_ic)
+            wsc_context_delete_surrounding (_focused_ic, offset, len);
     }
 
     void
     socket_helper_set_selection (int id, uint32 context_id, uint32 start, uint32 end) {
         LOGD ("client id:%d", id);
-        wsc_context_set_selection (_focused_ic, start, end);
+        if (_focused_ic)
+            wsc_context_set_selection (_focused_ic, start, end);
     }
 
     void
     send_private_command (int id, uint32 context_id, const String& command) {
         LOGD ("client id:%d", id);
         //panel_slot_send_private_command (context_id, command);
-        wl_input_method_context_private_command (_focused_ic->im_ctx, _focused_ic->serial, command.c_str ());
+        if (_focused_ic && _focused_ic->im_ctx)
+            wl_input_method_context_private_command (_focused_ic->im_ctx, _focused_ic->serial, command.c_str ());
     }
 
     void