From dfb824131740c83b082f8ad462e250b765c7dc8f Mon Sep 17 00:00:00 2001
From: Frank Praznik <[EMAIL REDACTED]>
Date: Sun, 18 Feb 2024 11:55:51 -0500
Subject: [PATCH] wayland: Don't pass null string pointers to
wl_cursor_theme_get_cursor
The function calls strcmp internally without checking for a null string parameter, and calling strcmp with a null parameter is undefined behavior.
(cherry picked from commit f24216c2bacaa2eb0751c70042f6c2e33a3fb78b)
---
src/video/wayland/SDL_waylandmouse.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/video/wayland/SDL_waylandmouse.c b/src/video/wayland/SDL_waylandmouse.c
index 7188ab78a6b8..59570e22e630 100644
--- a/src/video/wayland/SDL_waylandmouse.c
+++ b/src/video/wayland/SDL_waylandmouse.c
@@ -259,7 +259,7 @@ static SDL_bool wayland_get_system_cursor(SDL_VideoData *vdata, Wayland_CursorDa
cssname = SDL_GetCSSCursorName(cdata->system_cursor, &fallback_name);
cursor = WAYLAND_wl_cursor_theme_get_cursor(theme, cssname);
- if (!cursor) {
+ if (!cursor && fallback_name) {
cursor = WAYLAND_wl_cursor_theme_get_cursor(theme, fallback_name);
}