compositor: Fix crash when accessing null pointer 66/296366/1
authorSeunghun Lee <shiin.lee@samsung.com>
Wed, 26 Jul 2023 06:36:04 +0000 (15:36 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Wed, 26 Jul 2023 07:02:10 +0000 (16:02 +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: I40fd3910cd980d31823e8ba8fe3f4210fc52b515

src/bin/e_compositor.c

index 6ae74fd..1b05ee0 100644 (file)
@@ -1105,11 +1105,13 @@ _e_subsurface_from_ds_subsurface(struct ds_subsurface *ds_subsurface)
 static E_Subsurface *
 _e_subsurface_from_surface(E_Surface *surface)
 {
-   if (!ds_surface_is_subsurface(surface->ds_surface))
+   struct ds_surface *ds_subsurface;
+
+   ds_subsurface = ds_subsurface_from_surface(surface->ds_surface);
+   if (!ds_subsurface)
      return NULL;
 
-   return _e_subsurface_from_ds_subsurface(
-      ds_subsurface_from_surface(surface->ds_surface));
+   return _e_subsurface_from_ds_subsurface(ds_subsurface);
 }
 
 static E_Subsurface *