From 7c5a1eab110505029676deae777b8ef480d873fe Mon Sep 17 00:00:00 2001 From: Bastiaan Olij Date: Sun, 5 Aug 2018 14:22:19 +1000 Subject: [PATCH] Preventing crash when function returned null ptr --- binding_generator.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/binding_generator.py b/binding_generator.py index 1e0c5073..31376609 100644 --- a/binding_generator.py +++ b/binding_generator.py @@ -633,7 +633,11 @@ def generate_icall_implementation(icalls): if ret_type != "void": if is_class_type(ret_type): - source.append("\treturn (Object *) godot::nativescript_1_1_api->godot_nativescript_get_instance_binding_data(godot::_RegisterState::language_index, ret);") + source.append("\tif (ret) {") + source.append("\t\treturn (Object *) godot::nativescript_1_1_api->godot_nativescript_get_instance_binding_data(godot::_RegisterState::language_index, ret);") + source.append("\t}") + source.append("") + source.append("\treturn (Object *) ret;") else: source.append("\treturn ret;")