input: Fix segfault caused by the access null 90/279090/1
authorSeunghun Lee <shiin.lee@samsung.com>
Wed, 6 Jul 2022 07:31:04 +0000 (16:31 +0900)
committerSeunghun Lee <shiin.lee@samsung.com>
Tue, 2 Aug 2022 01:18:11 +0000 (10:18 +0900)
Change-Id: I5b45ab184dbd216de35ad032c03b469aab2116d8

src/input/input.c

index 8469d13..dbe1bb3 100644 (file)
@@ -171,14 +171,17 @@ handle_top_change(struct wl_listener *listener, void *data)
 
        input = wl_container_of(listener, input, top_change);
 
-       input->top_view = view;
-
-       if (input->top_view_destroy.notify)
+       if (input->top_view_destroy.notify) {
                wl_list_remove(&input->top_view_destroy.link);
-       else
+               input->top_view_destroy.notify = NULL;
+       }
+
+       if (view) {
                input->top_view_destroy.notify = handle_top_view_destroy;
+               wl_signal_add(&view->events.destroy, &input->top_view_destroy);
+       }
 
-       wl_signal_add(&view->events.destroy, &input->top_view_destroy);
+       input->top_view = view;
 }
 
 static void