Fix crash by freed object assign to typed variable

This commit is contained in:
ocean (they/them)
2023-02-15 09:42:53 -05:00
parent aa6ec76317
commit c45970739e
5 changed files with 56 additions and 6 deletions

View File

@@ -0,0 +1,7 @@
func test():
var x = Node.new()
x.free()
var ok = x
var bad : Node = x

View File

@@ -0,0 +1,6 @@
GDTEST_RUNTIME_ERROR
>> SCRIPT ERROR
>> on function: test()
>> analyzer/errors/native_freed_instance.gd
>> 7
>> Trying to assign invalid previously freed instance.

View File

@@ -0,0 +1,10 @@
class A extends Node:
pass
func test():
var x = A.new()
x.free()
var ok = x
var bad : A = x

View File

@@ -0,0 +1,6 @@
GDTEST_RUNTIME_ERROR
>> SCRIPT ERROR
>> on function: test()
>> analyzer/errors/script_freed_instance.gd
>> 10
>> Trying to assign invalid previously freed instance.