From 5392f04612831c3954d12154420df0cb510ddf7d Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Fri, 1 May 2026 06:10:00 +0300
Subject: [PATCH] SDL_UpperBlit: fix an oversight in commit 61e247df for issue
#244.
Otherwise NULL pointer dereference can happen in PrepBlitDestRect()
---
src/SDL12_compat.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/SDL12_compat.c b/src/SDL12_compat.c
index abc9e016f..f7c799709 100644
--- a/src/SDL12_compat.c
+++ b/src/SDL12_compat.c
@@ -7039,14 +7039,15 @@ SDL_UpperBlit(SDL12_Surface *src12, SDL12_Rect *srcrect12, SDL12_Surface *dst12,
SDL_Rect srcrect20, dstrect20;
int retval;
- PrepBlitDestRect(&dstrect20, dst12, dstrect12);
-
if ((src12 == NULL) || (dst12 == NULL)) {
return SDL20_SetError("SDL_UpperBlit: passed a NULL surface");
}
if ((src12->pixels == NULL) || (dst12->pixels == NULL)) {
return SDL20_SetError("SDL_UpperBlit: passed a surface with NULL pixels");
}
+
+ PrepBlitDestRect(&dstrect20, dst12, dstrect12);
+
if (SaveDestAlpha(src12, dst12, &dstrect20, &dstalpha) < 0) {
return -1;
}