surface: Fix crash when accessing null 74/296374/1 accepted/tizen/unified/20230726.163543 accepted/tizen/unified/20230727.055140
authorSeunghun Lee <shiin.lee@samsung.com>
Wed, 26 Jul 2023 07:52:42 +0000 (16:52 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Wed, 26 Jul 2023 08:16:46 +0000 (17:16 +0900)
This patch adds a null check before accessing the return value of
ds_subsurface_from_surface().

The return value of ds_subsurface_from_surface() can be null even though
the ds_surface_is_subsurface() returns true. That's the case when the
subsurface has been destroyed.

Change-Id: I112dd4770b678f73e946be9773633083db8ce68b

src/compositor/surface.c

index 5f883cc..b6a103b 100644 (file)
@@ -582,8 +582,8 @@ surface_handle_commit(struct wl_client *client, struct wl_resource *resource)
 
     ds_dbg("ds_surface(%p) commit", surface);
 
-    if (ds_surface_is_subsurface(surface)) {
-        subsurface = ds_subsurface_from_surface(surface);
+    subsurface = ds_subsurface_from_surface(surface);
+    if (subsurface) {
         subsurface_commit(subsurface);
         return;
     }