From 43e9c5b247b9344c99d1a023be064fc14a876cff Mon Sep 17 00:00:00 2001
From: Frank Praznik <[EMAIL REDACTED]>
Date: Tue, 3 Dec 2024 11:53:14 -0500
Subject: [PATCH] wayland: Check the returned display value for null
In reality, this condition will never occur, since the index is checked before calling the display retrieval function, but aggressive LTO with jump threading can generate a warning if this isn't explicitly checked.
(cherry picked from commit 91bb1bb6fd042677c2725a1c9e6e99cb71dda247)
---
src/video/wayland/SDL_waylandvideo.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/video/wayland/SDL_waylandvideo.c b/src/video/wayland/SDL_waylandvideo.c
index 636b5afbd9df9..9f7960aa2aa03 100644
--- a/src/video/wayland/SDL_waylandvideo.c
+++ b/src/video/wayland/SDL_waylandvideo.c
@@ -644,6 +644,11 @@ static void display_handle_done(void *data,
if (driverdata->index > -1) {
dpy = SDL_GetDisplay(driverdata->index);
+
+ /* XXX: This can never happen, but jump threading during aggressive LTO can generate a warning without this check. */
+ if (!dpy) {
+ dpy = &driverdata->placeholder;
+ }
} else {
dpy = &driverdata->placeholder;
}