From 847539afebe1019c2e1320eccfbe2334d30a2bcc Mon Sep 17 00:00:00 2001 From: David Gow Date: Wed, 1 Jun 2022 23:06:19 +0800 Subject: [PATCH] wayland: Only call libdecor_dispatch() if we've loaded libdecor As of #5703, we call libdecor_dispatch() in Wayland_WaitEventTimeout(), but this will crash if we don't load libdecor, as SDL_VideoData::shell.libdecor will be NULL. Since we don't load libdecor if we don't intend to use it (i.e., if should_use_libdecor returns false), this results in a crash under KDE in almost all circumstances. --- src/video/wayland/SDL_waylandevents.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/video/wayland/SDL_waylandevents.c b/src/video/wayland/SDL_waylandevents.c index 20fe6022e..b08da5bbe 100644 --- a/src/video/wayland/SDL_waylandevents.c +++ b/src/video/wayland/SDL_waylandevents.c @@ -295,7 +295,9 @@ Wayland_WaitEventTimeout(_THIS, int timeout) } #ifdef HAVE_LIBDECOR_H - libdecor_dispatch(d->shell.libdecor, timeout); + if (d->shell.libdecor) { + libdecor_dispatch(d->shell.libdecor, timeout); + } #endif /* wl_display_prepare_read() will return -1 if the default queue is not empty.