desktop-shell: Avoid NULL output dereference when getting surface label

When hotunplugging a display, the compositor will tear down the
corresponding output object.

Avoid NULL output dereferences by all surface label getters in
desktop-shell when hotunplugging happens.

Signed-off-by: Miguel A Vico Moya <mvicomoya@nvidia.com>
dev
Miguel A. Vico 5 years ago
parent 1ca4ed2015
commit 620f68dc4f
  1. 6
      desktop-shell/shell.c

@ -521,7 +521,7 @@ static int
focus_surface_get_label(struct weston_surface *surface, char *buf, size_t len) focus_surface_get_label(struct weston_surface *surface, char *buf, size_t len)
{ {
return snprintf(buf, len, "focus highlight effect for output %s", return snprintf(buf, len, "focus highlight effect for output %s",
surface->output->name); (surface->output ? surface->output->name : "NULL"));
} }
/* no-op func for checking focus surface */ /* no-op func for checking focus surface */
@ -2985,7 +2985,7 @@ static int
background_get_label(struct weston_surface *surface, char *buf, size_t len) background_get_label(struct weston_surface *surface, char *buf, size_t len)
{ {
return snprintf(buf, len, "background for output %s", return snprintf(buf, len, "background for output %s",
surface->output->name); (surface->output ? surface->output->name : "NULL"));
} }
static void static void
@ -3065,7 +3065,7 @@ static int
panel_get_label(struct weston_surface *surface, char *buf, size_t len) panel_get_label(struct weston_surface *surface, char *buf, size_t len)
{ {
return snprintf(buf, len, "panel for output %s", return snprintf(buf, len, "panel for output %s",
surface->output->name); (surface->output ? surface->output->name : "NULL"));
} }
static void static void

Loading…
Cancel
Save