Skip to content

Commit e69a003

Browse files
committed
Catch failed calls to classdb_get_method_bind()
When Godot fails to provide a method (e.g. invalid hash), this FFI method returned a null pointer. Instead of UB dereferencing that pointer, a panic is now caused.
1 parent 04c2323 commit e69a003

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

godot-codegen/src/class_generator.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,12 @@ fn make_method_definition(
575575
__method_name.string_sys(),
576576
#hash
577577
);
578+
assert!(
579+
!__method_bind.is_null(),
580+
"failed to load method {}::{} -- possible Godot and gdext version mismatch",
581+
#class_name_str,
582+
#method_name_str
583+
);
578584
let __call_fn = sys::interface_fn!(#function_provider);
579585
};
580586
let varcall_invocation = quote! {

0 commit comments

Comments
 (0)