commit 50b8225d2905440e6599e181e52a8912b006414e
parent 28dcc02fff6729df6a593bf92fc9ffd66019fa59
Author: Michael Forney <mforney@mforney.org>
Date: Fri, 29 Nov 2013 23:37:38 -0800
shell_surface: Check to make sure resource creation succeeds
Diffstat:
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/libswc/shell_surface.c b/libswc/shell_surface.c
@@ -177,7 +177,7 @@ struct swc_shell_surface * swc_shell_surface_new
shell_surface = malloc(sizeof *shell_surface);
if (!shell_surface)
- return NULL;
+ goto error0;
shell_surface->type = SHELL_SURFACE_TYPE_UNSPECIFIED;
swc_window_initialize(&shell_surface->window.base,
@@ -185,10 +185,19 @@ struct swc_shell_surface * swc_shell_surface_new
shell_surface->resource = wl_resource_create
(client, &wl_shell_surface_interface, 1, id);
+
+ if (!shell_surface->resource)
+ goto error1;
+
wl_resource_set_implementation(shell_surface->resource,
&shell_surface_implementation,
shell_surface, NULL);
return shell_surface;
+
+ error1:
+ free(shell_surface);
+ error0:
+ return NULL;
}