[Cogl] [PATCH 2/4] cogland: Don't leak the shell surface struct if requested twice

Neil Roberts neil at linux.intel.com
Thu Apr 11 09:11:14 PDT 2013


If the shell surface is requested twice then Cogland will hit an error
path but it would end up leaking the CoglandShellSurface struct it
allocated.
---
 examples/cogland.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/examples/cogland.c b/examples/cogland.c
index d9efa37..7231f02 100644
--- a/examples/cogland.c
+++ b/examples/cogland.c
@@ -971,7 +971,7 @@ get_shell_surface (struct wl_client *client,
                    struct wl_resource *surface_resource)
 {
   CoglandSurface *surface = surface_resource->data;
-  CoglandShellSurface *shell_surface = g_new0 (CoglandShellSurface, 1);
+  CoglandShellSurface *shell_surface;
 
   if (surface->has_shell_surface)
     {
@@ -981,6 +981,7 @@ get_shell_surface (struct wl_client *client,
       return;
     }
 
+  shell_surface = g_new0 (CoglandShellSurface, 1);
   shell_surface->resource.destroy = destroy_shell_surface;
   shell_surface->resource.object.id = id;
   shell_surface->resource.object.interface = &wl_shell_surface_interface;
-- 
1.7.11.3.g3c3efa5



More information about the Cogl mailing list