aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2024-02-29 06:49:08 +0000
committerDaniel Eklöf <daniel@ekloef.se>2024-02-29 07:16:20 +0000
commit6fd533ce138bbb2d026da8175353feb493b12b47 (patch)
tree94dfc395b9e89f3af1f148458dd3c09c3524044b
parentci: run x86+x64 builds in parallel (diff)
render: don't try to set a NULL xcursor image
render_xcursor_update() is called when we've loaded a new xcursor image, and needs to display it. The reason it's not pushed to the compositor immediately is to ensure we don't flood the Wayland socket with xcursor updates. Normally, it's only called when we *succeed* to load a new xcursor image. I.e. if we try to load a non-existing xcursor image, we never schedule an update. However, we _can_ still end up in render_xcursor_update() without a valid xcursor image. For example, we have loaded a valid xcursor image, and scheduled an update. But before the update runs, the user moves the cursor, and we try to load a new xcursor image. If it fails, we crash when the previously scheduled update finally runs. Closes #1624
-rw-r--r--CHANGELOG.md2
-rw-r--r--render.c19
2 files changed, 19 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6ca6d88a..0b06bf41 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -122,12 +122,14 @@
affect emojis.
* Pressing a modifier key while the kitty keyboard protocol is enabled
no longer resets the viewport, or clears the selection.
+* Crash when failing to load an xcursor image ([#1624][1624]).
[1531]: https://codeberg.org/dnkl/foot/issues/1531
[1573]: https://codeberg.org/dnkl/foot/issues/1573
[1568]: https://codeberg.org/dnkl/foot/issues/1568
[1552]: https://codeberg.org/dnkl/foot/issues/1552
[1610]: https://codeberg.org/dnkl/foot/issues/1610
+[1624]: https://codeberg.org/dnkl/foot/issues/1624
### Security
diff --git a/render.c b/render.c
index 4f0d2348..3ce8a226 100644
--- a/render.c
+++ b/render.c
@@ -4363,8 +4363,6 @@ render_xcursor_update(struct seat *seat)
return;
}
- xassert(seat->pointer.cursor != NULL);
-
const enum cursor_shape shape = seat->pointer.shape;
const char *const xcursor = seat->pointer.last_custom_xcursor;
@@ -4398,6 +4396,23 @@ render_xcursor_update(struct seat *seat)
LOG_DBG("setting %scursor shape using a client-side cursor surface",
seat->pointer.shape == CURSOR_SHAPE_CUSTOM ? "custom " : "");
+ if (seat->pointer.cursor == NULL) {
+ /*
+ * Normally, we never get here with a NULL-cursor, because we
+ * only schedule a cursor update when we succeed to load the
+ * cursor image.
+ *
+ * However, it is possible that we did succeed to load an
+ * image, and scheduled an update. But, *before* the scheduled
+ * update triggers, the user mvoes the pointer, and we try to
+ * load a new cursor image. This time failing.
+ *
+ * In this case, we have a NULL cursor, but the scheduled
+ * update is still scheduled.
+ */
+ return;
+ }
+
const float scale = seat->pointer.scale;
struct wl_cursor_image *image = seat->pointer.cursor->images[0];
struct wl_buffer *buf = wl_cursor_image_get_buffer(image);