shell: don't crash on create_common_surface() failure
authorPekka Paalanen <pekka.paalanen@collabora.co.uk>
Wed, 1 Oct 2014 11:03:56 +0000 (14:03 +0300)
committerPekka Paalanen <pekka.paalanen@collabora.co.uk>
Wed, 1 Oct 2014 11:58:46 +0000 (14:58 +0300)
Noticed while reading code, that create_common_surface() may return
NULL, and callers of its direct callers check for NULL, but the
intermediate function in between would crash.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
desktop-shell/shell.c

index 6ef36b5..810961f 100644 (file)
@@ -3879,6 +3879,9 @@ create_xdg_surface(struct shell_client *owner, void *shell,
        struct shell_surface *shsurf;
 
        shsurf = create_common_surface(owner, shell, surface, client);
+       if (!shsurf)
+               return NULL;
+
        shsurf->type = SHELL_SURFACE_TOPLEVEL;
 
        return shsurf;
@@ -3963,6 +3966,9 @@ create_xdg_popup(struct shell_client *owner, void *shell,
        struct shell_surface *shsurf;
 
        shsurf = create_common_surface(owner, shell, surface, client);
+       if (!shsurf)
+               return NULL;
+
        shsurf->type = SHELL_SURFACE_POPUP;
        shsurf->popup.shseat = seat;
        shsurf->popup.serial = serial;