From 71f3c35288e0b7a357918b285d9fbfa0bc8060dc Mon Sep 17 00:00:00 2001 From: rubidium42 Date: Sat, 12 Jun 2021 16:45:26 +0200 Subject: Fix #9353: [Script] Garbage collecting on priority queues could crash the game --- src/script/script_instance.cpp | 7 +++++-- src/script/script_instance.hpp | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'src') 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. -- cgit v1.2.3-70-g09d2