e_compositor: Fix crash when access null pointer 72/298072/1
authorSeunghun Lee <shiin.lee@samsung.com>
Thu, 31 Aug 2023 02:18:02 +0000 (11:18 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Thu, 31 Aug 2023 04:43:33 +0000 (13:43 +0900)
The return value of ds_subsurface_from_resource() can be null if given
subsurface resource is inert by the parent surface destroyed.

Change-Id: I56c5974e56c6c32fba0599aec97229cad4598544

src/bin/e_compositor.c

index 5967689..8321646 100644 (file)
@@ -165,7 +165,11 @@ e_comp_wl_subsurface_resource_stand_alone_mode_set(struct wl_resource *subsurfac
    E_Subsurface *sub;
 
    sub = _e_subsurface_from_resource(subsurface_resource);
-   EINA_SAFETY_ON_NULL_RETURN(sub);
+   if (!sub)
+     {
+        INF("The given subsurface resource(%p) seems inert.", subsurface_resource);
+        return;
+     }
 
    ELOGF("SUBSURFACE", "SUBSURF|STAND_ALONE", sub->surface->ec);
 
@@ -179,7 +183,11 @@ e_comp_wl_subsurface_resource_place_below_parent(struct wl_resource *subsurface_
    E_Comp_Wl_Client_Data *epc_cdata;
 
    sub = _e_subsurface_from_resource(subsurface_resource);
-   EINA_SAFETY_ON_NULL_RETURN(sub);
+   if (!sub)
+     {
+        INF("The given subsurface resource(%p) seems inert.", subsurface_resource);
+        return;
+     }
 
    EINA_SAFETY_ON_NULL_RETURN(sub->base.parent);
    epc_cdata = e_client_cdata_get(sub->base.parent);
@@ -1124,8 +1132,13 @@ _e_subsurface_from_surface(E_Surface *surface)
 static E_Subsurface *
 _e_subsurface_from_resource(struct wl_resource *resource)
 {
-   return _e_subsurface_from_ds_subsurface(
-      ds_subsurface_from_resource(resource));
+   struct ds_subsurface *ds_subsurface;
+
+   ds_subsurface = ds_subsurface_from_resource(resource);
+   if (!ds_subsurface)
+     return NULL;
+
+   return _e_subsurface_from_ds_subsurface(ds_subsurface);
 }
 
 static Eina_Bool