SDL: wayland: Fix incorrect dereference when sorting icon surfaces (6f054)

From 6f0544dcca6ed58f67a3cc5adb7d2a7a43a4e402 Mon Sep 17 00:00:00 2001
From: Frank Praznik <[EMAIL REDACTED]>
Date: Tue, 30 Jun 2026 10:15:28 -0400
Subject: [PATCH] wayland: Fix incorrect dereference when sorting icon surfaces

(cherry picked from commit 2f1cf4629c9e76ec2999c8a348e4c55b46c0088d)
---
 src/video/wayland/SDL_waylandmouse.c  | 4 ++--
 src/video/wayland/SDL_waylandwindow.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/video/wayland/SDL_waylandmouse.c b/src/video/wayland/SDL_waylandmouse.c
index de755100f24a0..2e94c451865f3 100644
--- a/src/video/wayland/SDL_waylandmouse.c
+++ b/src/video/wayland/SDL_waylandmouse.c
@@ -717,8 +717,8 @@ static bool Wayland_GetSystemCursor(SDL_CursorData *cdata, SDL_WaylandCursorStat
 
 static int surface_sort_callback(const void *a, const void *b)
 {
-    SDL_Surface *s1 = *(SDL_Surface **)a;
-    SDL_Surface *s2 = *(SDL_Surface **)b;
+    const SDL_Surface *s1 = *(const SDL_Surface **)a;
+    const SDL_Surface *s2 = *(const SDL_Surface **)b;
 
     return (s1->w * s1->h) <= (s2->w * s2->h) ? -1 : 1;
 }
diff --git a/src/video/wayland/SDL_waylandwindow.c b/src/video/wayland/SDL_waylandwindow.c
index 9392dc74a31db..639d0748263a0 100644
--- a/src/video/wayland/SDL_waylandwindow.c
+++ b/src/video/wayland/SDL_waylandwindow.c
@@ -3026,8 +3026,8 @@ void Wayland_SetWindowTitle(SDL_VideoDevice *_this, SDL_Window *window)
 
 static int icon_sort_callback(const void *a, const void *b)
 {
-    SDL_Surface *s1 = (SDL_Surface *)a;
-    SDL_Surface *s2 = (SDL_Surface *)b;
+    const SDL_Surface *s1 = *(const SDL_Surface **)a;
+    const SDL_Surface *s2 = *(const SDL_Surface **)b;
 
     return (s1->w * s1->h) <= (s2->w * s2->h) ? -1 : 1;
 }