Add NULL checking to prevent dereferenced problem. 66/254866/1 accepted/tizen/unified/20210316.151423 submit/tizen/20210312.022457
authorJoonbum Ko <joonbum.ko@samsung.com>
Wed, 10 Mar 2021 06:38:40 +0000 (15:38 +0900)
committerJoonbum Ko <joonbum.ko@samsung.com>
Wed, 10 Mar 2021 06:38:40 +0000 (15:38 +0900)
Change-Id: I6ff1a170342dd25822739dc0d4f11ff95c43e492
Signed-off-by: Joonbum Ko <joonbum.ko@samsung.com>
samples/tri.c

index b42cd55..b3986d6 100644 (file)
@@ -1789,16 +1789,18 @@ static const struct wl_shell_surface_listener shell_surface_listener = {
 static void demo_create_window(struct demo *demo) {
        demo->wl_surface = wl_compositor_create_surface(demo->compositor);
 
-       demo->shell_surface = wl_shell_get_shell_surface(demo->shell, demo->wl_surface);
+    if (demo->wl_surface) {
+           demo->shell_surface = wl_shell_get_shell_surface(demo->shell, demo->wl_surface);
 
-       if (demo->shell_surface) {
-               wl_shell_surface_add_listener(demo->shell_surface,
-                                                                         &shell_surface_listener, demo);
-               wl_shell_surface_set_toplevel(demo->shell_surface);
-               wl_shell_surface_set_title(demo->shell_surface, APP_SHORT_NAME);
-       }
+           if (demo->shell_surface) {
+               wl_shell_surface_add_listener(demo->shell_surface,
+                                                                         &shell_surface_listener, demo);
+               wl_shell_surface_set_toplevel(demo->shell_surface);
+               wl_shell_surface_set_title(demo->shell_surface, APP_SHORT_NAME);
+           }
 
-       wl_surface_set_user_data(demo->wl_surface, demo);
+           wl_surface_set_user_data(demo->wl_surface, demo);
+    }
 }
 #endif // _WIN32