gdext
gdext copied to clipboard
Fix null-check against uninitialized pointer in `Gd::from_sys_init_opt()`
Background: type-ptr is passed to a Godot FFI function, representing the return type as an output parameter. This type-ptr contains the address of an object-ptr.
Problem: the object-ptr was not initialized to null before passing it to the FFI function. Since these functions' return value is optional, they may not write to the return pointer (output parameter). However, code was still checking the object-ptr for being null after the FFI, when it could be uninitialized.
An additional point addressed by this PR is the relatively complex implementation around reusing Gd::from_sys_init()
. Now, Gd::from_sys_init_opt()
directly uses Gd::from_obj_sys()
, significantly simplifying the logic.
This may fix the crash when starting Dodge-the-Creeps that some users on Linux reported.