Fix indexing failure in NativeScriptLanguage::unregister_binding_functions.

binding_functions.size() and an instance's binding_data.size() can get out of sync. They sync up when an instance's bindings are requested. When binding functions are registered after creating an instance's bindings, the instance's bindings are out of sync until requested again. If they're never requested, they're never synced.

unregister_binding_functions indexes into binding_data, but only checks that its safe to index into binding_functions. When they're out of sync, indexing fails.

This revision checks that it's safe to index into binding_data.

(cherry picked from commit a4a0e64245)
This commit is contained in:
Frank Secilia 2019-05-15 15:28:55 -04:00 committed by Rémi Verschelde
parent dcc9c1cc2a
commit 8ee5dc5850
1 changed files with 1 additions and 1 deletions

View File

@ -1309,7 +1309,7 @@ void NativeScriptLanguage::unregister_binding_functions(int p_idx) {
for (Set<Vector<void *> *>::Element *E = binding_instances.front(); E; E = E->next()) {
Vector<void *> &binding_data = *E->get();
if (binding_data[p_idx] && binding_functions[p_idx].second.free_instance_binding_data)
if (p_idx < binding_data.size() && binding_data[p_idx] && binding_functions[p_idx].second.free_instance_binding_data)
binding_functions[p_idx].second.free_instance_binding_data(binding_functions[p_idx].second.data, binding_data[p_idx]);
}