[escher] Fix layout count verification in ExprLayField::handleEvWText

Change-Id: Ie56e61aa10c907c6ab0dac8814b9ed46aac669f8
This commit is contained in:
Léa Saviot
2018-05-17 09:52:34 +02:00
committed by EmilieNumworks
parent 6035bd904b
commit bde05b3d8b

View File

@@ -215,7 +215,8 @@ int ExpressionLayoutField::writeTextInBuffer(char * buffer, int bufferLength) {
}
bool ExpressionLayoutField::handleEventWithText(const char * text, bool indentation) {
if (m_contentView.expressionView()->numberOfLayouts() >= k_maxNumberOfLayouts) {
int currentNumberOfLayouts = m_contentView.expressionView()->numberOfLayouts();
if (currentNumberOfLayouts >= k_maxNumberOfLayouts) {
return true;
}
Poincare::Expression * resultExpression = Poincare::Expression::parse(text);
@@ -224,7 +225,7 @@ bool ExpressionLayoutField::handleEventWithText(const char * text, bool indentat
}
Poincare::ExpressionLayout * resultLayout = resultExpression->createLayout();
delete resultExpression;
if (resultLayout->numberOfDescendants(true) >= k_maxNumberOfLayouts) {
if (currentNumberOfLayouts + resultLayout->numberOfDescendants(true) >= k_maxNumberOfLayouts) {
delete resultLayout;
return false;
}