summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium42 <rubidium@openttd.org>2021-06-12 16:45:26 +0200
committerrubidium42 <rubidium42@users.noreply.github.com>2021-06-12 19:58:14 +0200
commit71f3c35288e0b7a357918b285d9fbfa0bc8060dc (patch)
treef574c7a15ef525811516474ee99606b6d02b70c2 /src
parent40cec34836a694e7388a4421d746e5238a57b608 (diff)
downloadopenttd-71f3c35288e0b7a357918b285d9fbfa0bc8060dc.tar.xz
Fix #9353: [Script] Garbage collecting on priority queues could crash the game
Diffstat (limited to 'src')
-rw-r--r--src/script/script_instance.cpp7
-rw-r--r--src/script/script_instance.hpp2
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.