wayland-input: assign NULL after xkb_keymap_unref and add NULL checking 86/264286/1
authorDuna Oh <duna.oh@samsung.com>
Wed, 15 Sep 2021 02:00:38 +0000 (11:00 +0900)
committerSung-Jin Park <sj76.park@samsung.com>
Wed, 15 Sep 2021 12:05:51 +0000 (21:05 +0900)
Change-Id: I02514f41fceef3cb47abed1094ee25391f78784d

src/modules/modality_keyboard/wayland-input.c

index 2468f50..c7a322c 100644 (file)
@@ -213,7 +213,11 @@ keyboard_keymap(void *data, struct wl_keyboard *keyboard, unsigned int format, i
                        return;
                }
 
-               if(keymap) xkb_keymap_unref(keymap);
+               if(keymap)
+               {
+                       xkb_keymap_unref(keymap);
+                       keymap = NULL;
+               }
                keymap = xkb_map_new_from_string(xkb_context, map, XKB_KEYMAP_FORMAT_TEXT_V1, 0);
                if(!keymap) {
                        LOGE("... Failed to get keymap from fd(%d)\n", fd);
@@ -412,6 +416,7 @@ void _xkb_context_shutdown(void)
                return;
 
        xkb_context_unref(xkb_context);
+       xkb_context = NULL;
 }
 
 static void
@@ -537,7 +542,6 @@ _cb_handle_data(void *data, Ecore_Fd_Handler *hdl)
        return ECORE_CALLBACK_RENEW;
 
 err:
-       fd_hdl = NULL;
        LOGE("Wayland Socket Error : %s\n", eina_error_msg_get(errno));
        return ECORE_CALLBACK_CANCEL;
 }
@@ -601,15 +605,48 @@ void _wl_init(void)
 
 void _wl_shutdown(void)
 {
-       tizen_keyrouter_destroy(tz_keyrouter);
-       wl_keyboard_release(keyboard);
-       wl_seat_destroy(seat);
-       wl_display_disconnect(display);
+       if (tz_keyrouter)
+       {
+               tizen_keyrouter_destroy(tz_keyrouter);
+               tz_keyrouter = NULL;
+       }
+       if (keyboard)
+       {
+               wl_keyboard_release(keyboard);
+               keyboard = NULL;
+       }
+       if (seat)
+       {
+               wl_seat_destroy(seat);
+               seat = NULL;
+       }
+
+       if (fd_hdl)
+       {
+               ecore_main_fd_handler_del(fd_hdl);
+               fd_hdl = NULL;
+       }
+
+       if (registry)
+       {
+               wl_registry_destroy(registry);
+               registry = NULL;
+       }
+
+       if (display)
+       {
+               wl_display_disconnect(display);
+               display = NULL;
+       }
 }
 
 void _keymap_shutdown(void)
 {
-       if(keymap) xkb_keymap_unref(keymap);
+       if(keymap)
+       {
+               xkb_keymap_unref(keymap);
+               keymap = NULL;
+       }
 }
 
 void wayland_input_init(void)