summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorAntonio Dell'Annunziata <contact@antonio-da.dev>2022-07-28 18:52:15 +0200
committerAntonio Dell'Annunziata <contact@antonio-da.dev>2022-07-28 18:52:29 +0200
commite03b7b1935954bb075d8d975a9b7a3a73c7cfa84 (patch)
tree7b335ace96279c18d816752a72a311f2869005ec /modules
parentc4d7a5d22a8c4f88966d43076266f26a52987bf6 (diff)
fix(gdscript): Fix out of bounds crash after reloading member variables
The crash happens because the members Vector is resized, while the member_indices_cache still has the old indices saved. On deleting a member from the script this can result to a cached index of 1 while the members Vector size is only 1.
Diffstat (limited to 'modules')
-rw-r--r--modules/gdscript/gdscript.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp
index a34bf6ef82..fcd846bc6f 100644
--- a/modules/gdscript/gdscript.cpp
+++ b/modules/gdscript/gdscript.cpp
@@ -1636,8 +1636,6 @@ const Vector<Multiplayer::RPCConfig> GDScriptInstance::get_rpc_methods() const {
void GDScriptInstance::reload_members() {
#ifdef DEBUG_ENABLED
- members.resize(script->member_indices.size()); //resize
-
Vector<Variant> new_members;
new_members.resize(script->member_indices.size());
@@ -1649,6 +1647,8 @@ void GDScriptInstance::reload_members() {
}
}
+ members.resize(new_members.size()); //resize
+
//apply
members = new_members;