aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2025-06-04 21:53:11 +0200
committerPřemysl Eric Janouch <p@janouch.name>2025-06-04 21:54:04 +0200
commitd8f785eae54d2b9898cc4a6b8d3c96957161538a (patch)
tree38f32eab5a84ecf48c61aaa3fbe3c332167c1f25
parent31ae40085206dc365a15fd6e9d13978e392f8b35 (diff)
downloadliberty-master.tar.gz
liberty-master.tar.xz
liberty-master.zip
liberty-xdg: don't crash on missing X11 atomsHEADorigin/mastermaster
They can be missing in bare configurations, such as Sway + XWayland.
-rw-r--r--liberty-xdg.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/liberty-xdg.c b/liberty-xdg.c
index be0746a..a918592 100644
--- a/liberty-xdg.c
+++ b/liberty-xdg.c
@@ -86,24 +86,30 @@ xdg_xsettings_update (struct xdg_xsettings *self, Display *dpy)
// TODO: We're supposed to lock the server.
// TODO: We're supposed to trap X errors.
char *selection = xstrdup_printf ("_XSETTINGS_S%d", DefaultScreen (dpy));
- Window owner
- = XGetSelectionOwner (dpy, XInternAtom (dpy, selection, True));
+ Atom selection_atom = XInternAtom (dpy, selection, True);
free (selection);
+ if (!selection_atom)
+ return;
+
+ Window owner = XGetSelectionOwner (dpy, selection_atom);
if (!owner)
return;
+ Atom xsettings_atom = XInternAtom (dpy, "_XSETTINGS_SETTINGS", True);
+ if (!xsettings_atom)
+ return;
+
Atom actual_type = None;
int actual_format = 0;
unsigned long nitems = 0, bytes_after = 0;
unsigned char *buffer = NULL;
- Atom xsettings = XInternAtom (dpy, "_XSETTINGS_SETTINGS", True);
int status = XGetWindowProperty (dpy,
owner,
- xsettings,
+ xsettings_atom,
0L,
LONG_MAX,
False,
- xsettings,
+ xsettings_atom,
&actual_type,
&actual_format,
&nitems,
@@ -112,7 +118,7 @@ xdg_xsettings_update (struct xdg_xsettings *self, Display *dpy)
if (status != Success || !buffer)
return;
- if (actual_type != xsettings
+ if (actual_type != xsettings_atom
|| actual_format != 8
|| nitems < 12)
goto fail;