[plasma/kwin] src/wayland: wayland: use QPointer for the xdg_popup parent surface

Vlad Zahorodnii <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 72e9cb50465971bda64ee39d06aa18e8cedaf0d5 by Vlad Zahorodnii, on behalf of zhang shoucheng.
Committed on 10/08/2026 at 09:32.
Pushed by vladz into branch 'master'.

wayland: use QPointer for the xdg_popup parent surface

This is a defensive fix. parentSurface was a raw pointer that was
never cleared. Normally the popup is destroyed before its parent
surface, but an abnormal or malicious client can destroy the parent
wl_surface first and then send xdg_popup.reposition, which would
dereference the freed pointer. Use a QPointer so the pointer is
automatically nulled when the parent surface is destroyed.

M  +2    -1    src/wayland/xdgshell_p.h

https://invent.kde.org/plasma/kwin/-/commit/72e9cb50465971bda64ee39d06aa18e8cedaf0d5

diff --git a/src/wayland/xdgshell_p.h b/src/wayland/xdgshell_p.h
index 0fdd5041cdd..6f47eba8b1b 100644
--- a/src/wayland/xdgshell_p.h
+++ b/src/wayland/xdgshell_p.h
@@ -7,6 +7,7 @@
 #pragma once
 
 #include <QIcon>
+#include <QPointer>
 
 #include "qwayland-server-xdg-shell.h"
 #include "xdgshell.h"
@@ -194,7 +195,7 @@ public:
     void reset();
 
     XdgPopupInterface *q;
-    SurfaceInterface *parentSurface = nullptr;
+    QPointer<SurfaceInterface> parentSurface;
     XdgSurfaceInterface *xdgSurface;
     XdgPositioner positioner;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.