From edcc1f6e8029569e0efa0215438b09bd7449e9e2 Mon Sep 17 00:00:00 2001 From: Arthur Camouseigt Date: Fri, 7 Aug 2020 10:27:43 +0200 Subject: [PATCH] [Poincare/integral_layout.cpp] Fixed crash due to infinite loop Changed previousNestedIntegral method to prevent integrals located in integral bounds to be considered as nested. Change-Id: Id8cc4369f53c278ac59039fde1c2818af2ccacab --- poincare/src/integral_layout.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/poincare/src/integral_layout.cpp b/poincare/src/integral_layout.cpp index 253d429ca..6d6119560 100644 --- a/poincare/src/integral_layout.cpp +++ b/poincare/src/integral_layout.cpp @@ -251,8 +251,13 @@ IntegralLayoutNode * IntegralLayoutNode::previousNestedIntegral() { return nullptr; } if (p->type() == Type::IntegralLayout) { - // Parent can be an integral - return static_cast(p); + // Parent is an integral. Checking if the child is its integrand or not + if (p->childAtIndex(0) == this) { + return static_cast(p); + } else { + // If this is not parent's integrand, it means that it is either a bound or differential + return nullptr; + } } else if (p->type() == Type::HorizontalLayout) { // Or can be a Horizontal layout himself contained in an integral LayoutNode * prev = p->parent();