diff options
author | rubidium42 <rubidium@openttd.org> | 2021-06-12 16:45:26 +0200 |
---|---|---|
committer | rubidium42 <rubidium42@users.noreply.github.com> | 2021-06-12 19:58:14 +0200 |
commit | 71f3c35288e0b7a357918b285d9fbfa0bc8060dc (patch) | |
tree | f574c7a15ef525811516474ee99606b6d02b70c2 /src/script | |
parent | 40cec34836a694e7388a4421d746e5238a57b608 (diff) | |
download | openttd-71f3c35288e0b7a357918b285d9fbfa0bc8060dc.tar.xz |
Fix #9353: [Script] Garbage collecting on priority queues could crash the game
Diffstat (limited to 'src/script')
-rw-r--r-- | src/script/script_instance.cpp | 7 | ||||
-rw-r--r-- | src/script/script_instance.hpp | 2 |
2 files changed, 6 insertions, 3 deletions
diff --git a/src/script/script_instance.cpp b/src/script/script_instance.cpp index 7c2fa43d6..c354126ca 100644 --- a/src/script/script_instance.cpp +++ b/src/script/script_instance.cpp @@ -254,9 +254,12 @@ void ScriptInstance::GameLoop() } } -void ScriptInstance::CollectGarbage() const +void ScriptInstance::CollectGarbage() { - if (this->is_started && !this->IsDead()) this->engine->CollectGarbage(); + if (this->is_started && !this->IsDead()) { + ScriptObject::ActiveInstance active(this); + this->engine->CollectGarbage(); + } } /* static */ void ScriptInstance::DoCommandReturn(ScriptInstance *instance) diff --git a/src/script/script_instance.hpp b/src/script/script_instance.hpp index 4709c44e2..7db4f5ea8 100644 --- a/src/script/script_instance.hpp +++ b/src/script/script_instance.hpp @@ -68,7 +68,7 @@ public: /** * Let the VM collect any garbage. */ - void CollectGarbage() const; + void CollectGarbage(); /** * Get the storage of this script. |