From 6c1b7fd899f72136a1cc17eb9ae81746d8d98572 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20J=2E=20Est=C3=A9banez?= Date: Tue, 25 Jul 2017 05:11:00 +0200 Subject: [PATCH] Fix Node::move_child() crash if moving to the end plus one Fixes #9820. --- scene/main/node.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scene/main/node.cpp b/scene/main/node.cpp index 26d1deadf94..c3849f79dfa 100755 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -311,6 +311,11 @@ void Node::move_child(Node *p_child, int p_pos) { ERR_FAIL_COND(data.blocked > 0); } + // Specifying one place beyond the end + // means the same as moving to the last position + if (p_pos == data.children.size()) + p_pos--; + if (p_child->data.pos == p_pos) return; //do nothing