From 01d359c1df703cea1ebb4a03dccc2940d345ca0b Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Sat, 8 Nov 2025 10:01:54 -0800
Subject: [PATCH] Don't create a larger surface than we need when scaling
---
src/video/SDL_surface.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/video/SDL_surface.c b/src/video/SDL_surface.c
index 5f1e96c03597f..d5936e1aba661 100644
--- a/src/video/SDL_surface.c
+++ b/src/video/SDL_surface.c
@@ -1310,14 +1310,15 @@ bool SDL_BlitSurfaceUncheckedScaled(SDL_Surface *src, const SDL_Rect *srcrect, S
SDL_PixelFormat fmt;
tmprect.x = 0;
tmprect.y = 0;
- tmprect.w = src->w;
- tmprect.h = src->h;
+ tmprect.w = srcrect->w;
+ tmprect.h = srcrect->h;
if (SDL_BYTESPERPIXEL(dst->format) == 4 && dst->format != SDL_PIXELFORMAT_ARGB2101010) {
fmt = dst->format;
} else {
fmt = SDL_PIXELFORMAT_ARGB8888;
}
- tmp1 = SDL_CreateSurface(src->w, src->h, fmt);
+ // FIXME: We really want a SDL_DuplicateSurface() with a rectangle here
+ tmp1 = SDL_CreateSurface(tmprect.w, tmprect.h, fmt);
SDL_BlitSurfaceUnchecked(src, srcrect, tmp1, &tmprect);
srcrect2.x = 0;