From 6c37d5b57f79eb008be25f71af9dff73f5e7daa0 Mon Sep 17 00:00:00 2001 From: Frank Praznik Date: Tue, 7 Feb 2023 11:41:23 -0500 Subject: [PATCH] x11: Cast the dot clock value to 64-bit when calculating the refresh rate The Xrandr dot clock value is declared as an unsigned long and the result when multiplying by 100 can overflow on a 32-bit system. Explicitly cast it to Sint64 to ensure that no overflow will occur. --- src/video/x11/SDL_x11modes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/video/x11/SDL_x11modes.c b/src/video/x11/SDL_x11modes.c index da58c19fd..85701886a 100644 --- a/src/video/x11/SDL_x11modes.c +++ b/src/video/x11/SDL_x11modes.c @@ -195,7 +195,7 @@ static SDL_bool CheckXRandR(Display *display, int *major, int *minor) static float CalculateXRandRRefreshRate(const XRRModeInfo *info) { if (info->hTotal && info->vTotal) { - return ((100 * info->dotClock) / (info->hTotal * info->vTotal)) / 100.0f; + return ((100 * (Sint64)info->dotClock) / (info->hTotal * info->vTotal)) / 100.0f; } return 0.0f; }