From 00dcffbc69a8feef1735a66b7b6eae3cd39188f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a=20Saviot?= Date: Tue, 16 Oct 2018 10:09:00 +0200 Subject: [PATCH] [apps] Return uninitialized exp if record type does not match exp type In global context. This fixes the computation of a->a(a) in calculation, which crashed. --- apps/shared/global_context.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/shared/global_context.cpp b/apps/shared/global_context.cpp index cd63ee6a4..6da6d61be 100644 --- a/apps/shared/global_context.cpp +++ b/apps/shared/global_context.cpp @@ -49,7 +49,9 @@ Poincare::Expression GlobalContext::ExpressionFromFunctionRecord(Ion::Storage::R if (record.isNull() || record.value().size == 0) { return Expression(); } - assert(Ion::Storage::FullNameHasExtension(record.fullName(), funcExtension, strlen(funcExtension))); + if (!Ion::Storage::FullNameHasExtension(record.fullName(), funcExtension, strlen(funcExtension))) { + return Expression(); + } /* An function record value has metadata before the expression. To get the * expression, use the funciton record handle. */ StorageCartesianFunction f = StorageCartesianFunction(record); @@ -101,6 +103,9 @@ const Expression GlobalContext::ExpressionForSymbolAndRecord(const SymbolAbstrac const Expression GlobalContext::ExpressionForActualSymbol(const SymbolAbstract & symbol, Ion::Storage::Record r) { assert(symbol.type() == ExpressionNode::Type::Symbol); + if (!Ion::Storage::FullNameHasExtension(r.fullName(), expExtension, strlen(expExtension))) { + return Expression(); + } // Constant symbols Symbol s = static_cast(symbol); if (s.isPi()) {