From e69a003e09aa23907e865121b2535f61f03c4296 Mon Sep 17 00:00:00 2001 From: Jan Haller Date: Wed, 5 Apr 2023 23:16:14 +0200 Subject: [PATCH] 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. --- godot-codegen/src/class_generator.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/godot-codegen/src/class_generator.rs b/godot-codegen/src/class_generator.rs index b27eb91a9..c03f267a6 100644 --- a/godot-codegen/src/class_generator.rs +++ b/godot-codegen/src/class_generator.rs @@ -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! {