From 10b0618c07091cf8caed853667e3b0eb7b070ec8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20Krezovi=C4=87?= Date: Thu, 23 Jun 2016 11:59:30 +0200 Subject: [PATCH] desktop-shell: Return NULL when no outputs are present MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently, get_default_output returns a first member of the linked list, which can never be NULL. This is problematic, as the function would return a dangling pointer and NULL pointer checks wouldn't work where needed and some of the invalid members would get accessed that way, resulting in a crash. Reviewed-by: Quentin Glidic Reviewed-by: Pekka Paalanen Signed-off-by: Armin Krezović --- desktop-shell/shell.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c index 2c881765..7deba555 100644 --- a/desktop-shell/shell.c +++ b/desktop-shell/shell.c @@ -688,6 +688,9 @@ shell_configuration(struct desktop_shell *shell) struct weston_output * get_default_output(struct weston_compositor *compositor) { + if (wl_list_empty(&compositor->output_list)) + return NULL; + return container_of(compositor->output_list.next, struct weston_output, link); }