From 5d6eb4a5a5aac19d251421ef0d9a74046e1e3674 Mon Sep 17 00:00:00 2001 From: Sylvain Date: Sat, 20 Jan 2024 06:33:38 +0100 Subject: [PATCH] Fixed overflow in SDL_SoftStretch() (see #8878) (cherry picked from commit 7b02d328fa691a18583fdc762541c7fb8c1ba09b) --- src/video/SDL_stretch.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/video/SDL_stretch.c b/src/video/SDL_stretch.c index 2de77f58d..80517dff7 100644 --- a/src/video/SDL_stretch.c +++ b/src/video/SDL_stretch.c @@ -149,8 +149,10 @@ static int SDL_UpperSoftStretch(SDL_Surface *src, const SDL_Rect *srcrect, #define BILINEAR___START \ int i; \ - int fp_sum_h, fp_step_h, left_pad_h, right_pad_h; \ - int fp_sum_w, fp_step_w, left_pad_w, right_pad_w; \ + Sint64 fp_sum_h; \ + int fp_step_h, left_pad_h, right_pad_h; \ + Sint64 fp_sum_w; \ + int fp_step_w, left_pad_w, right_pad_w; \ int fp_sum_w_init, left_pad_w_init, right_pad_w_init, dst_gap, middle_init; \ get_scaler_datas(src_h, dst_h, &fp_sum_h, &fp_step_h, &left_pad_h, &right_pad_h); \ get_scaler_datas(src_w, dst_w, &fp_sum_w, &fp_step_w, &left_pad_w, &right_pad_w); \ @@ -194,12 +196,12 @@ static int SDL_UpperSoftStretch(SDL_Surface *src, const SDL_Rect *srcrect, // OK with clang 12.0.0 / Xcode __attribute__((noinline)) #endif -static void get_scaler_datas(int src_nb, int dst_nb, int *fp_start, int *fp_step, int *left_pad, int *right_pad) +static void get_scaler_datas(int src_nb, int dst_nb, Sint64 *fp_start, int *fp_step, int *left_pad, int *right_pad) { int step = FIXED_POINT(src_nb) / (dst_nb); /* source step in fixed point */ int x0 = FP_ONE / 2; /* dst first pixel center at 0.5 in fixed point */ - int fp_sum; + Sint64 fp_sum; int i; #if 0 /* scale to source coordinates */