From 0b23b2bd588da735200cfeef7a229f5adf3d60fc Mon Sep 17 00:00:00 2001 From: "U. Artie Eoff" Date: Wed, 15 Jan 2014 14:45:59 -0800 Subject: [PATCH] shell: validate create_focus_surface results Signed-off-by: U. Artie Eoff --- desktop-shell/shell.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c index b3e1c4f..7d7563f 100644 --- a/desktop-shell/shell.c +++ b/desktop-shell/shell.c @@ -525,7 +525,12 @@ create_focus_surface(struct weston_compositor *ec, surface->output = output; surface->configure_private = fsurf; - fsurf->view = weston_view_create (surface); + fsurf->view = weston_view_create(surface); + if (fsurf->view == NULL) { + weston_surface_destroy(surface); + free(fsurf); + return NULL; + } fsurf->view->output = output; weston_surface_set_size(surface, output->width, output->height); @@ -719,9 +724,17 @@ animate_focus_change(struct desktop_shell *shell, struct workspace *ws, output = get_default_output(shell->compositor); if (ws->fsurf_front == NULL && (from || to)) { ws->fsurf_front = create_focus_surface(shell->compositor, output); - ws->fsurf_back = create_focus_surface(shell->compositor, output); + if (ws->fsurf_front == NULL) + return; ws->fsurf_front->view->alpha = 0.0; + + ws->fsurf_back = create_focus_surface(shell->compositor, output); + if (ws->fsurf_back == NULL) { + focus_surface_destroy(ws->fsurf_front); + return; + } ws->fsurf_back->view->alpha = 0.0; + focus_surface_created = true; } else { wl_list_remove(&ws->fsurf_front->view->layer_link); -- 2.7.4