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.
This commit is contained in:
Antonio Dell'Annunziata 2022-07-28 18:52:15 +02:00
parent c4d7a5d22a
commit e03b7b1935
No known key found for this signature in database
GPG Key ID: 8D2BB16641F06E94

View File

@ -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;