diff --git a/apps/calculation/calculation.cpp b/apps/calculation/calculation.cpp index af4b8b18b..2c2badd93 100644 --- a/apps/calculation/calculation.cpp +++ b/apps/calculation/calculation.cpp @@ -72,17 +72,29 @@ KDCoordinate Calculation::height(Context * context) { LayoutRef inputLayout = createInputLayout(); if (inputLayout.isAllocationFailure()) { /* If there is not enough tree pool space to create the layout, return a - * default height. Do not store it in m_height in case some memory get + * default height. Do not store it in m_height in case some memory gets * freed afterwards. */ return k_heightComputationFailureHeight; } KDCoordinate inputHeight = inputLayout.layoutSize().height(); LayoutRef approximateLayout = createApproximateOutputLayout(context); + if (approximateLayout.isAllocationFailure()) { + /* If there is not enough tree pool space to create the layout, return a + * default height. Do not store it in m_height in case some memory gets + * freed afterwards. */ + return k_heightComputationFailureHeight; + } KDCoordinate approximateOutputHeight = approximateLayout.layoutSize().height(); if (shouldOnlyDisplayApproximateOutput(context)) { m_height = inputHeight+approximateOutputHeight; } else { LayoutRef exactLayout = createExactOutputLayout(context); + if (exactLayout.isAllocationFailure()) { + /* If there is not enough tree pool space to create the layout, return a + * default height. Do not store it in m_height in case some memory gets + * freed afterwards. */ + return k_heightComputationFailureHeight; + } KDCoordinate exactOutputHeight = exactLayout.layoutSize().height(); KDCoordinate outputHeight = max(exactLayout.baseline(), approximateLayout.baseline()) + max(exactOutputHeight-exactLayout.baseline(), approximateOutputHeight-approximateLayout.baseline()); m_height = inputHeight + outputHeight;