Fix defect detected by static analysis tool 81/211681/1
authorJihoon Kim <jihoon48.kim@samsung.com>
Thu, 8 Aug 2019 05:41:23 +0000 (14:41 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Thu, 8 Aug 2019 05:41:26 +0000 (14:41 +0900)
Explicit null dereferenced (FORWARD_NULL)
Passing null pointer display to wl_display_create_queue, which dereferences it.

Change-Id: I4518fe4c1debc3bbb3fc6cbc2d5357d3578a09d1
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
ism/extras/wayland_immodule/wayland_imcontext.c

index a28505d..5c2fa9b 100644 (file)
@@ -3356,22 +3356,25 @@ wayland_im_context_filter_event(Ecore_IMF_Context    *ctx,
             struct wl_display *display = NULL;
             if (wl2_display)
                 display = ecore_wl2_display_get(wl2_display);
-            struct wl_event_queue *queue = wl_display_create_queue(display);
 
-            if (display && queue) {
-                while (ecore_time_get() - start_time < WAIT_FOR_FILTER_DONE_SECOND && _focused_ctx == ctx && wl_display_roundtrip_queue(display, queue) != -1) {
-                    wl_display_dispatch_pending(display);
-                    if (imcontext->last_key_event_filter.serial == serial) {
-                        ret = imcontext->last_key_event_filter.state;
-                        break;
-                    } else if (imcontext->last_key_event_filter.serial > serial)
-                        break;
+            if (display) {
+                struct wl_event_queue *queue = wl_display_create_queue(display);
+
+                if (queue) {
+                    while (ecore_time_get() - start_time < WAIT_FOR_FILTER_DONE_SECOND && _focused_ctx == ctx && wl_display_roundtrip_queue(display, queue) != -1) {
+                        wl_display_dispatch_pending(display);
+                        if (imcontext->last_key_event_filter.serial == serial) {
+                            ret = imcontext->last_key_event_filter.state;
+                            break;
+                        } else if (imcontext->last_key_event_filter.serial > serial)
+                            break;
+                    }
+
+                    wl_event_queue_destroy(queue);
                 }
-            }
 
-            if (queue)
-                wl_event_queue_destroy(queue);
-            LOGD ("elapsed : %.3f ms, serial (last, require) : (%d, %d)", (ecore_time_get() - start_time)*1000, imcontext->last_key_event_filter.serial, serial);
+                LOGD ("elapsed : %.3f ms, serial (last, require) : (%d, %d)", (ecore_time_get() - start_time)*1000, imcontext->last_key_event_filter.serial, serial);
+            }
         } while (0);
 
         if (type == ECORE_IMF_EVENT_KEY_DOWN) {