# SDL: wayland: Don't pass null string pointers to wl\_cursor\_theme\_get\_cursor (dfb82)

**URL:** <https://discourse.libsdl.org/t/sdl-wayland-dont-pass-null-string-pointers-to-wl-cursor-theme-get-cursor-dfb82/49291>\
**Category:** SDL Commits\
**Created:** [February 18, 2024, 5:38pm UTC](https://discourse.libsdl.org/t/sdl-wayland-dont-pass-null-string-pointers-to-wl-cursor-theme-get-cursor-dfb82/49291 "2024-02-18T17:38:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![SDLPushPostBot](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/sdlpushpostbot/32/4370_2.png) [@SDLPushPostBot](https://discourse.libsdl.org/u/SDLPushPostBot)\
**Post date:** [February 18, 2024, 5:38pm UTC](https://discourse.libsdl.org/t/sdl-wayland-dont-pass-null-string-pointers-to-wl-cursor-theme-get-cursor-dfb82/49291/1 "2024-02-18T17:38:03Z")

</div>

> <https://github.com/libsdl-org/SDL/commit/dfb824131740c83b082f8ad462e250b765c7dc8f>
>
> The function calls strcmp internally without checking for a null string paramete…r, and calling strcmp with a null parameter is undefined behavior.
> 
> (cherry picked from commit f24216c2bacaa2eb0751c70042f6c2e33a3fb78b)

```diff
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);
     }
 

```
