Skip to content

Commit

Permalink
Merge #216
Browse files Browse the repository at this point in the history
216: Catch failed calls to `classdb_get_method_bind()` r=Bromeon a=Bromeon

When Godot fails to provide a method (e.g. invalid hash), this FFI method returns a null pointer. Instead of UB from dereferencing that pointer, a panic is now caused.

Found as a result of godotengine/godot#75779.

Co-authored-by: Jan Haller <bromeon@gmail.com>
  • Loading branch information
bors[bot] and Bromeon authored Apr 10, 2023
2 parents 498e54c + e69a003 commit 558a6d3
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 @@ -592,6 +592,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 558a6d3

Please sign in to comment.