瀏覽代碼

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.
Frank Praznik 2 年之前
父節點
當前提交
6c37d5b57f
共有 1 個文件被更改,包括 1 次插入1 次删除
  1. 1 1
      src/video/x11/SDL_x11modes.c

+ 1 - 1
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)
 static float CalculateXRandRRefreshRate(const XRRModeInfo *info)
 {
 {
     if (info->hTotal && info->vTotal) {
     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;
     return 0.0f;
 }
 }