From 02a116217d8dcd0ffc47db50d73b354334cd2b7c Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 4 Dec 2023 21:55:34 -0800 Subject: [PATCH] Fixed Arithmetic overflow: Using operator '-' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator '-' to avoid overflow (io.2). --- src/events/SDL_mouse.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/events/SDL_mouse.c b/src/events/SDL_mouse.c index eb9a863f6..44c732e0f 100644 --- a/src/events/SDL_mouse.c +++ b/src/events/SDL_mouse.c @@ -799,8 +799,8 @@ static int SDL_PrivateSendMouseButton(Uint64 timestamp, SDL_Window *window, SDL_ Uint64 now = SDL_GetTicks(); if (now >= (clickstate->last_timestamp + mouse->double_click_time) || - SDL_fabs(mouse->x - clickstate->last_x) > mouse->double_click_radius || - SDL_fabs(mouse->y - clickstate->last_y) > mouse->double_click_radius) { + SDL_fabs((double)mouse->x - clickstate->last_x) > mouse->double_click_radius || + SDL_fabs((double)mouse->y - clickstate->last_y) > mouse->double_click_radius) { clickstate->click_count = 0; } clickstate->last_timestamp = now;