From 5df737bb3cd0f110705ee9850c4aa54ba78d08c8 Mon Sep 17 00:00:00 2001
From: Frank Praznik <[EMAIL REDACTED]>
Date: Wed, 20 Mar 2024 15:42:42 -0400
Subject: [PATCH] wayland: Check the returned display pointer before
dereferencing
Fixes a crash when all displays are disconnected.
---
src/video/wayland/SDL_waylandopengles.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/video/wayland/SDL_waylandopengles.c b/src/video/wayland/SDL_waylandopengles.c
index cf911492a01e2..22311a63e65fa 100644
--- a/src/video/wayland/SDL_waylandopengles.c
+++ b/src/video/wayland/SDL_waylandopengles.c
@@ -126,7 +126,7 @@ int Wayland_GLES_SwapWindow(_THIS, SDL_Window *window)
struct wl_display *display = videodata->display;
SDL_VideoDisplay *sdldisplay = SDL_GetDisplayForWindow(window);
/* 1/3 speed (or 20hz), so we'll progress even if throttled to zero. */
- const Uint32 max_wait = SDL_GetTicks() + (sdldisplay->current_mode.refresh_rate ? (3000 / sdldisplay->current_mode.refresh_rate) : 50);
+ const Uint32 max_wait = SDL_GetTicks() + (sdldisplay && sdldisplay->current_mode.refresh_rate ? (3000 / sdldisplay->current_mode.refresh_rate) : 50);
while (SDL_AtomicGet(&data->swap_interval_ready) == 0) {
Uint32 now;