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.
This commit is contained in:
Frank Praznik 2023-02-07 11:41:23 -05:00
parent 20a4e31a12
commit 6c37d5b57f

View file

@ -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;
}