From 7066c6491ecd0879fd2ee51c4b305ed40de37810 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Mon, 23 Feb 2026 09:52:10 -0800
Subject: [PATCH] Fixed cursor mask padding calculation
(cherry picked from commit 2e4ac09b1f768bf601812c3ac606129732db0239)
---
src/video/windows/SDL_windowsmouse.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/video/windows/SDL_windowsmouse.c b/src/video/windows/SDL_windowsmouse.c
index d3746505ed5f0..2cd4e726f32d2 100644
--- a/src/video/windows/SDL_windowsmouse.c
+++ b/src/video/windows/SDL_windowsmouse.c
@@ -218,7 +218,9 @@ static bool WriteIconSurface(SDL_IOStream *dst, SDL_Surface *surface)
static void *CreateIconMask(SDL_Surface *surface, size_t *mask_size)
{
Uint8 *dst;
- const int pitch = ((surface->w + 15) & ~15) / 8;
+ const int w = (surface->w + 7) / 8;
+ const int pad = (((w) % 4) ? (4 - ((w) % 4)) : 0);
+ const int pitch = (w + pad);
const size_t size = pitch * surface->h;
static const unsigned char masks[] = { 0x80, 0x40, 0x20, 0x10, 0x8, 0x4, 0x2, 0x1 };