Skip to content

Commit

Permalink
Catch failed calls to classdb_get_method_bind()
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Bromeon committed Apr 5, 2023
1 parent 04c2323 commit e69a003
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions godot-codegen/src/class_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,12 @@ fn make_method_definition(
__method_name.string_sys(),
#hash
);
assert!(
!__method_bind.is_null(),
"failed to load method {}::{} -- possible Godot and gdext version mismatch",
#class_name_str,
#method_name_str
);
let __call_fn = sys::interface_fn!(#function_provider);
};
let varcall_invocation = quote! {
Expand Down

0 comments on commit e69a003

Please sign in to comment.