From b0728c704815caa56566f4e35c6cfb57ff0feff0 Mon Sep 17 00:00:00 2001 From: Levi Neely Date: Sat, 28 Mar 2026 06:54:35 +0100 Subject: [PATCH] =?UTF-8?q?wayland:=20Phase=2048=20=E2=80=94=20guard=20NET?= =?UTF-8?q?WM=20init/update/cleanup=20functions=20against=20NULL=20dpy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add if (!dpy) return guards to wNETWMInitStuff, wNETWMCleanup, wNETWMUpdateDesktop, wNETWMGetCurrentDesktopFromHint, wNETWMUpdateActions, and updateWindowOpacity so the Wayland backend path does not crash calling XChangeProperty/XDeleteProperty/ XGetWindowProperty on a NULL display. Co-Authored-By: Claude Sonnet 4.6 --- src/wmspec.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/wmspec.c b/src/wmspec.c index 2cb5e38..47fc176 100644 --- a/src/wmspec.c +++ b/src/wmspec.c @@ -362,6 +362,8 @@ void wNETWMUpdateDesktop(WScreen *scr) long *views, sizes[2]; int count, i; + if (!dpy) return; /* Wayland: no X11 root-window properties */ + if (scr->workspace_count == 0) return; @@ -389,6 +391,8 @@ int wNETWMGetCurrentDesktopFromHint(WScreen *scr) int count; unsigned char *prop; + if (!dpy) return -1; /* Wayland: no X11 _NET_CURRENT_DESKTOP hint */ + prop = PropGetCheckProperty(scr->root_win, net_current_desktop, WA_CARDINAL, 0, 1, &count); if (prop) { int desktop = *(long *)prop; @@ -576,6 +580,8 @@ static void updateWindowOpacity(WWindow *wwin) unsigned long items, rest; unsigned long *property; + if (!dpy) return; /* Wayland: no X11 _NET_WM_WINDOW_OPACITY */ + if (!wwin->frame) return; @@ -651,6 +657,8 @@ void wNETWMInitStuff(WScreen *scr) NetData *data; int i; + if (!dpy) return; /* Wayland: no X11 NETWM atoms or root-window hints */ + #ifdef DEBUG_WMSPEC wmessage("wNETWMInitStuff"); #endif @@ -708,6 +716,8 @@ void wNETWMCleanup(WScreen *scr) { int i; + if (!dpy) return; /* Wayland: no X11 root-window atoms to clean up */ + for (i = 0; i < wlengthof(atomNames); i++) XDeleteProperty(dpy, scr->root_win, *atomNames[i].atom); } @@ -717,6 +727,8 @@ void wNETWMUpdateActions(WWindow *wwin, Bool del) Atom action[10]; /* nr of actions atoms defined */ int i = 0; + if (!dpy) return; /* Wayland: no X11 _NET_WM_ALLOWED_ACTIONS property */ + if (del) { XDeleteProperty(dpy, wwin->client_win, net_wm_allowed_actions); return;