summarylogtreecommitdiffstats
path: root/0007-desktop-shell-Avoid-NULL-output-dereference-when-get.patch
blob: c913b0f9d9d350e00d318e9278456f507eda9a96 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
From f98d9cf40a5dc11a7f87bc674bb6e3333c2321d1 Mon Sep 17 00:00:00 2001
From: "Miguel A. Vico" <mvicomoya@nvidia.com>
Date: Wed, 25 Sep 2019 11:23:13 -0700
Subject: [PATCH 7/8] desktop-shell: Avoid NULL output dereference when getting
 surface label
X-NVConfidentiality: public

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>
---
 desktop-shell/shell.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
index f94a4ca2..00ee1079 100644
--- a/desktop-shell/shell.c
+++ b/desktop-shell/shell.c
@@ -521,7 +521,7 @@ static int
 focus_surface_get_label(struct weston_surface *surface, char *buf, size_t len)
 {
 	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 */
@@ -2985,7 +2985,7 @@ static int
 background_get_label(struct weston_surface *surface, char *buf, size_t len)
 {
 	return snprintf(buf, len, "background for output %s",
-			surface->output->name);
+			(surface->output ? surface->output->name : "NULL"));
 }
 
 static void
@@ -3065,7 +3065,7 @@ static int
 panel_get_label(struct weston_surface *surface, char *buf, size_t len)
 {
 	return snprintf(buf, len, "panel for output %s",
-			surface->output->name);
+			(surface->output ? surface->output->name : "NULL"));
 }
 
 static void
-- 
2.21.0