From 6cad845ed728dec5096348d5f8ac9c0ccd3e6a27 Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Sun, 28 Feb 2021 20:09:57 -0500
Subject: [PATCH] Report error instead of crashing if blitting a NULL surface.
This matches what SDL 1.2 classic does.
Fixes Dungeons of Dredmor crashing upon starting actual gameplay.
---
src/SDL12_compat.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/SDL12_compat.c b/src/SDL12_compat.c
index 6bd5547..91f5040 100644
--- a/src/SDL12_compat.c
+++ b/src/SDL12_compat.c
@@ -3297,7 +3297,10 @@ SDL_UpperBlit(SDL12_Surface *src12, SDL12_Rect *srcrect12, SDL12_Surface *dst12,
SDL_Rect srcrect20, dstrect20;
int retval;
- if (SaveDestAlpha(src12, dst12, &dstalpha) < 0) {
+ if ((src12 == NULL) || (dst12 == NULL)) {
+ SDL_SetError("SDL_UpperBlit: passed a NULL surface");
+ return -1;
+ } else if (SaveDestAlpha(src12, dst12, &dstalpha) < 0) {
return -1;
}