From c21bc48a7074d8589a2764e287b09d06fd764a2c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Carl=20=C3=85stholm?= <[EMAIL REDACTED]>
Date: Tue, 28 Jan 2025 10:19:57 +0100
Subject: [PATCH] Fix undefined behavior in SDL_windowsmouse.c
This fix prevents C undefined behavior from being invoked on Windows
if the user's configured cursor speed is below 6.
---
src/video/windows/SDL_windowsmouse.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/video/windows/SDL_windowsmouse.c b/src/video/windows/SDL_windowsmouse.c
index 3a1c7cac8924c..a0e9c2550f10d 100644
--- a/src/video/windows/SDL_windowsmouse.c
+++ b/src/video/windows/SDL_windowsmouse.c
@@ -710,7 +710,7 @@ void WIN_UpdateMouseSystemScale(void)
int v = 10;
if (SystemParametersInfo(SPI_GETMOUSESPEED, 0, &v, 0)) {
v = SDL_max(1, SDL_min(v, 20));
- data->dpiscale = SDL_max(SDL_max(v, (v - 2) << 2), (v - 6) << 3);
+ data->dpiscale = SDL_max(SDL_max(v, (v - 2) * 4), (v - 6) * 8);
}
int params[3];