e_comp_wl_shell: Do not reference 'ec' if e_object_unref() returns '0'. 93/200193/3
authorSeunghun <shiin.lee@samsung.com>
Wed, 20 Feb 2019 02:10:11 +0000 (11:10 +0900)
committerGwanglim Lee <gl77.lee@samsung.com>
Thu, 7 Mar 2019 01:42:39 +0000 (01:42 +0000)
The instance of E_Client is supposed to be freed if e_object_unref()
returns '0'. Hense, processing cannot access 'ec' in that case.

Change-Id: I842512455a8fac831363bba4a62f10bf43f271fa

src/bin/e_comp_wl_shell.c

index 2170e6a9f11d6adf9b9f884c4eca44c8ea9834e5..5bbc777ab16379d29bcb94c7074fd1a62824ecb7 100644 (file)
@@ -371,6 +371,8 @@ e_shell_e_client_destroy(E_Client *ec)
 {
    EINA_SAFETY_ON_NULL_RETURN(ec);
 
+   ELOGF("SHELL", "Destroy shell surface", ec);
+
    if (e_policy_visibility_client_grab_cancel(ec))
      {
         ELOGF("POL_VIS", "CLIENT VIS ON(temp).", ec);
@@ -378,8 +380,23 @@ e_shell_e_client_destroy(E_Client *ec)
         ec->visibility.changed = 1;
      }
 
-   if ((e_object_unref(E_OBJECT(ec))) &&
-       (!e_object_is_del(E_OBJECT(ec))))
+   /* remove this 'ec' from parent's transients list */
+   if (ec->parent)
+     {
+        ec->parent->transients =
+           eina_list_remove(ec->parent->transients, ec);
+        if (ec->parent->modal == ec) ec->parent->modal = NULL;
+        ec->parent = NULL;
+     }
+
+   /* The instance of E_Client is supposed to be freed if e_object_unref returns '0'.
+    * Then there is nothing to do here */
+   if (e_object_unref(E_OBJECT(ec)) == 0)
+     return;
+
+   /* wl_resource_destroy(ec->comp_data->shell.surface); */
+
+   if (!e_object_is_del(E_OBJECT(ec)))
      {
         if (ec->comp_data->mapped)
           {
@@ -390,22 +407,9 @@ e_shell_e_client_destroy(E_Client *ec)
                   ec->comp_data->shell.unmap(ec->comp_data->shell.surface);
                }
           }
-        if (ec->parent)
-          {
-             ec->parent->transients =
-                eina_list_remove(ec->parent->transients, ec);
-             if (ec->parent->modal == ec) ec->parent->modal = NULL;
-             ec->parent = NULL;
-          }
-        /* wl_resource_destroy(ec->comp_data->shell.surface); */
+        ec->comp_data->shell.surface = NULL;
+        e_policy_client_unmap(ec);
      }
-
-   if (ec->comp_data)
-     ec->comp_data->shell.surface = NULL;
-
-   ELOGF("SHELL", "Destroy shell surface", ec);
-
-   e_policy_client_unmap(ec);
 }
 
 static void