Skip to content

Commit 558a6d3

Browse files
bors[bot]Bromeon
andauthored
Merge #216
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 <[email protected]>
2 parents 498e54c + e69a003 commit 558a6d3

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
@@ -592,6 +592,12 @@ fn make_method_definition(
592592
__method_name.string_sys(),
593593
#hash
594594
);
595+
assert!(
596+
!__method_bind.is_null(),
597+
"failed to load method {}::{} -- possible Godot and gdext version mismatch",
598+
#class_name_str,
599+
#method_name_str
600+
);
595601
let __call_fn = sys::interface_fn!(#function_provider);
596602
};
597603
let varcall_invocation = quote! {

0 commit comments

Comments
 (0)