From f37ef1303d5693b1098aa87bb6be53ae35f72b3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a=20Saviot?= Date: Wed, 1 Aug 2018 16:52:42 +0200 Subject: [PATCH] [poincare] Fix TreeReference::replaceTreeChild --- poincare/src/tree_reference.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/poincare/src/tree_reference.cpp b/poincare/src/tree_reference.cpp index 60a770487..a917a9234 100644 --- a/poincare/src/tree_reference.cpp +++ b/poincare/src/tree_reference.cpp @@ -118,7 +118,10 @@ void TreeReference::replaceTreeChild(TreeReference oldChild, TreeReference newCh } // Move the new child - TreePool::sharedPool()->move(oldChild.node()->nextSibling(), newChild.node(), newChild.numberOfChildren()); + TreePool::sharedPool()->move(oldChild.node(), newChild.node(), newChild.numberOfChildren()); + /* We could have moved the new node to oldChild.node()->nextSibling(), but + * nextSibling is not computed correctly if we inserted an + * AllocationFailureNode next to newChild. */ if (!p.isDefined()) { newChild.node()->retain();