Browse Source

Merge pull request #44604 from lyuma/gdscript_dictionary_crash

GDScript: Fix crash when iterating through empty dictionary.
Rémi Verschelde 4 years ago
parent
commit
3e9a40cdc0
1 changed files with 1 additions and 1 deletions
  1. 1 1
      modules/gdscript/gdscript_vm.cpp

+ 1 - 1
modules/gdscript/gdscript_vm.cpp

@@ -2306,10 +2306,10 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
 
 				Dictionary *dict = VariantInternal::get_dictionary(container);
 				const Variant *next = dict->next(nullptr);
-				*counter = *next;
 
 				if (!dict->is_empty()) {
 					GET_INSTRUCTION_ARG(iterator, 2);
+					*counter = *next;
 					*iterator = *next;
 
 					// Skip regular iterate.