From 2ac83b733cb31aaaea14687ed97c0d7383a6ee3f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 2 Jan 2022 15:06:57 +0100 Subject: [PATCH] - SW: clear some pointers before killing actors in TerminateLevel. KillActor is an in-game function which may produce undefined behavior if being run on a partially deinitialized level. All actor pointers it may operate upon should be cleared before taking down the actors.cpp --- source/common/rendering/hwrenderer/data/hw_dynlightdata.h | 2 +- source/games/sw/src/game.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/source/common/rendering/hwrenderer/data/hw_dynlightdata.h b/source/common/rendering/hwrenderer/data/hw_dynlightdata.h index d54b7427e..7da1c1b5a 100644 --- a/source/common/rendering/hwrenderer/data/hw_dynlightdata.h +++ b/source/common/rendering/hwrenderer/data/hw_dynlightdata.h @@ -6,7 +6,7 @@ // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or +// the Free Software Foundation, either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, diff --git a/source/games/sw/src/game.cpp b/source/games/sw/src/game.cpp index 90298a33b..e79a957e6 100644 --- a/source/games/sw/src/game.cpp +++ b/source/games/sw/src/game.cpp @@ -533,6 +533,12 @@ void TerminateLevel(void) // Kill User memory and delete sprites SWSpriteIterator it; while (auto actor = it.Next()) + { + actor->user.targetActor = nullptr; + actor->user.flameActor = nullptr; + } + it.Reset(); + while (auto actor = it.Next()) { KillActor(actor); }