From b1cbecf268e6716dcec218602499391d828ada6f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 26 Aug 2022 20:05:28 +0200 Subject: [PATCH] - Duke/RR: do not spawn sprites with invalid picnums. RRRA E1L7 has a respawner that will spawn an invalid sprite crashing the game. --- source/games/duke/src/spawn.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/games/duke/src/spawn.cpp b/source/games/duke/src/spawn.cpp index b338d92ac..050c9250a 100644 --- a/source/games/duke/src/spawn.cpp +++ b/source/games/duke/src/spawn.cpp @@ -53,6 +53,8 @@ DDukeActor* EGS(sectortype* whatsectp, int s_x, int s_y, int s_z, int s_pn, int8 { // sector pointer must be strictly validated here or the engine will crash. if (whatsectp == nullptr || !validSectorIndex(sectnum(whatsectp))) return nullptr; + // spawning out of range sprites will also crash. + if (s_pn < 0 || s_pn >= MAXTILES) return nullptr; auto act = static_cast(::InsertActor(RUNTIME_CLASS(DDukeActor), whatsectp, s_ss)); if (act == nullptr) return nullptr;