From 27d7760f41d0c819075db37d3234d2587092e682 Mon Sep 17 00:00:00 2001 From: Danil Alexeev Date: Thu, 28 Mar 2024 21:57:56 +0300 Subject: GDScript: Fix uninitialized local variables not being reset --- modules/gdscript/gdscript_vm.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'modules/gdscript/gdscript_vm.cpp') diff --git a/modules/gdscript/gdscript_vm.cpp b/modules/gdscript/gdscript_vm.cpp index 1a8c22cc11..3cb011b251 100644 --- a/modules/gdscript/gdscript_vm.cpp +++ b/modules/gdscript/gdscript_vm.cpp @@ -234,6 +234,7 @@ void (*type_init_function_table[])(Variant *) = { &&OPCODE_SET_STATIC_VARIABLE, \ &&OPCODE_GET_STATIC_VARIABLE, \ &&OPCODE_ASSIGN, \ + &&OPCODE_ASSIGN_NULL, \ &&OPCODE_ASSIGN_TRUE, \ &&OPCODE_ASSIGN_FALSE, \ &&OPCODE_ASSIGN_TYPED_BUILTIN, \ @@ -1256,6 +1257,16 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a } DISPATCH_OPCODE; + OPCODE(OPCODE_ASSIGN_NULL) { + CHECK_SPACE(2); + GET_VARIANT_PTR(dst, 0); + + *dst = Variant(); + + ip += 2; + } + DISPATCH_OPCODE; + OPCODE(OPCODE_ASSIGN_TRUE) { CHECK_SPACE(2); GET_VARIANT_PTR(dst, 0); -- cgit v1.2.3