From 230581f4a8992dc1f1c0d030375c964104be4c26 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 4 Dec 2023 21:28:27 -0800 Subject: [PATCH] Fixed warning C26451: 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/render/software/SDL_rotate.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/render/software/SDL_rotate.c b/src/render/software/SDL_rotate.c index 637653a5b3..7689b68a55 100644 --- a/src/render/software/SDL_rotate.c +++ b/src/render/software/SDL_rotate.c @@ -296,8 +296,8 @@ static void transformSurfaceRGBA(SDL_Surface *src, SDL_Surface *dst, int isin, i int y; for (y = 0; y < dst->h; y++) { int x; - double src_x = (rect_dest->x + 0 + 0.5 - center->x); - double src_y = (rect_dest->y + y + 0.5 - center->y); + double src_x = ((double)rect_dest->x + 0 + 0.5 - center->x); + double src_y = ((double)rect_dest->y + y + 0.5 - center->y); int sdx = (int)((icos * src_x - isin * src_y) + cx - fp_half); int sdy = (int)((isin * src_x + icos * src_y) + cy - fp_half); for (x = 0; x < dst->w; x++) { @@ -364,8 +364,8 @@ static void transformSurfaceRGBA(SDL_Surface *src, SDL_Surface *dst, int isin, i int y; for (y = 0; y < dst->h; y++) { int x; - double src_x = (rect_dest->x + 0 + 0.5 - center->x); - double src_y = (rect_dest->y + y + 0.5 - center->y); + double src_x = ((double)rect_dest->x + 0 + 0.5 - center->x); + double src_y = ((double)rect_dest->y + y + 0.5 - center->y); int sdx = (int)((icos * src_x - isin * src_y) + cx - fp_half); int sdy = (int)((isin * src_x + icos * src_y) + cy - fp_half); for (x = 0; x < dst->w; x++) { @@ -437,8 +437,8 @@ static void transformSurfaceY(SDL_Surface *src, SDL_Surface *dst, int isin, int */ for (y = 0; y < dst->h; y++) { int x; - double src_x = (rect_dest->x + 0 + 0.5 - center->x); - double src_y = (rect_dest->y + y + 0.5 - center->y); + double src_x = ((double)rect_dest->x + 0 + 0.5 - center->x); + double src_y = ((double)rect_dest->y + y + 0.5 - center->y); int sdx = (int)((icos * src_x - isin * src_y) + cx - fp_half); int sdy = (int)((isin * src_x + icos * src_y) + cy - fp_half); for (x = 0; x < dst->w; x++) {