From 57ef77376fc369f3d9bb86278a22ce2a73ace732 Mon Sep 17 00:00:00 2001 From: Marcelo Fernandez Date: Sat, 30 Sep 2017 11:18:50 -0300 Subject: [PATCH] VisualScript crashfix when returns are too few --- modules/visual_script/visual_script_func_nodes.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/visual_script/visual_script_func_nodes.cpp b/modules/visual_script/visual_script_func_nodes.cpp index c17265d2754..8d73de98892 100644 --- a/modules/visual_script/visual_script_func_nodes.cpp +++ b/modules/visual_script/visual_script_func_nodes.cpp @@ -763,7 +763,7 @@ public: NodePath node_path; int input_args; bool validate; - bool returns; + int returns; VisualScriptFunctionCall::RPCCallMode rpc_mode; StringName function; StringName singleton; @@ -856,7 +856,13 @@ public: } } else if (returns) { if (call_mode == VisualScriptFunctionCall::CALL_MODE_INSTANCE) { - *p_outputs[1] = v.call(function, p_inputs + 1, input_args, r_error); + if (returns >= 2) { + *p_outputs[1] = v.call(function, p_inputs + 1, input_args, r_error); + } else { + r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD; + r_error_str = "Invalid returns count for call_mode == CALL_MODE_INSTANCE"; + return 0; + } } else { *p_outputs[0] = v.call(function, p_inputs + 1, input_args, r_error); }