summaryrefslogtreecommitdiff
path: root/kde-plasma/kwayland-server/files/kwayland-server-5.24.4-guard-subsurface-parent-access.patch
blob: e40189ab27444f0eb228d61fd9b30a966b6fe83e (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
From 6dcf73adaafeaa40c05e22df5f1c10af88df362b Mon Sep 17 00:00:00 2001
From: David Edmundson <kde@davidedmundson.co.uk>
Date: Wed, 30 Mar 2022 14:57:12 +0100
Subject: [PATCH] Guard subsurface parent access.

Whilst a subsurface must have a parent at the time of creation, the
lifespan is not guaranteed afterwards.

It's a weird thing for a client to do, but we need to not crash
afterwards.

If the parent surface is destroyed we should consider the surface
unmapped.

BUG: 452044


(cherry picked from commit 1d2424a56a13dc55aeab699a38234a7cafa091d8)
---
 src/server/surface_interface.cpp | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/server/surface_interface.cpp b/src/server/surface_interface.cpp
index ef2584f4..8bfac95f 100644
--- a/src/server/surface_interface.cpp
+++ b/src/server/surface_interface.cpp
@@ -678,7 +678,13 @@ void SurfaceInterfacePrivate::commitFromCache()
 
 bool SurfaceInterfacePrivate::computeEffectiveMapped() const
 {
-    return bufferRef && (!subSurface || subSurface->parentSurface()->isMapped());
+    if (!bufferRef) {
+        return false;
+    }
+    if (subSurface) {
+        return subSurface->parentSurface() && subSurface->parentSurface()->isMapped();
+    }
+    return true;
 }
 
 void SurfaceInterfacePrivate::updateEffectiveMapped()
-- 
GitLab