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;