summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2021-02-19 15:49:56 +0100
committerGitHub <noreply@github.com>2021-02-19 15:49:56 +0100
commit4c4931eeae3e848a4833207f03291d18ede4d3b8 (patch)
treeed86f4dca17e3784311573d3a7909c2e61fe5411 /scene
parent480c5f28abdc50cc1d525feb44fc42a44883b8f8 (diff)
parent4a468171e5428047e198474433cce2040a35a052 (diff)
Merge pull request #46196 from nmrkr/visual-shader-invalid-forced-connect
Fix crash when calling connect_nodes_forced with invalid params
Diffstat (limited to 'scene')
-rw-r--r--scene/resources/visual_shader.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/scene/resources/visual_shader.cpp b/scene/resources/visual_shader.cpp
index d8e63e47be..859546694f 100644
--- a/scene/resources/visual_shader.cpp
+++ b/scene/resources/visual_shader.cpp
@@ -585,6 +585,12 @@ bool VisualShader::is_port_types_compatible(int p_a, int p_b) const {
void VisualShader::connect_nodes_forced(Type p_type, int p_from_node, int p_from_port, int p_to_node, int p_to_port) {
ERR_FAIL_INDEX(p_type, TYPE_MAX);
Graph *g = &graph[p_type];
+
+ ERR_FAIL_COND(!g->nodes.has(p_from_node));
+ ERR_FAIL_INDEX(p_from_port, g->nodes[p_from_node].node->get_output_port_count());
+ ERR_FAIL_COND(!g->nodes.has(p_to_node));
+ ERR_FAIL_INDEX(p_to_port, g->nodes[p_to_node].node->get_input_port_count());
+
Connection c;
c.from_node = p_from_node;
c.from_port = p_from_port;