[apps/calc] approximateOutput handles unparsable m_approximateOutputText

This fixes a crash when computing:
[[1, 0, -1, 0][0, 1, 1, 0][0, 2, 0, 1][1, 0, 0, 1]]^(-1)
This commit is contained in:
Léa Saviot
2019-03-29 09:59:23 +01:00
committed by EmilieNumworks
parent c84216d918
commit 52ae2a2643

View File

@@ -138,6 +138,11 @@ Expression Calculation::approximateOutput(Context * context) {
/* To ensure that the expression 'm_output' is a matrix or a complex, we
* call 'evaluate'. */
Expression exp = Expression::Parse(m_approximateOutputText);
if (exp.isUninitialized()) {
/* TODO: exp might be uninitialized because the serialization did not fit in
* the buffer. Put a special error instead of "undef". */
return Undefined::Builder();
}
return PoincareHelpers::Approximate<double>(exp, *context);
}