diff --git a/apps/shared/global_context.cpp b/apps/shared/global_context.cpp index 6cfd868fd..c3bdc1ec8 100644 --- a/apps/shared/global_context.cpp +++ b/apps/shared/global_context.cpp @@ -58,16 +58,10 @@ Ion::Storage::Record GlobalContext::RecordWithName(const char * name) { return Ion::Storage::sharedStorage()->recordBaseNamedWithExtensions(name, extensions, 2); } -const char * GlobalContext::ExtensionForExpression(const Expression & exp) { - // TODO Once we have matrix exact reducing, add a .mat extension and check here if the root is a matrix - // TODO .seq - if (exp.type() == ExpressionNode::Type::Function) { - return funcExtension; - } - return expExtension; -} - const Expression GlobalContext::expressionForSymbolAndRecord(const SymbolAbstract & symbol, Ion::Storage::Record r) { + if (r.isNull()) { + return Expression(); + } if (symbol.type() == ExpressionNode::Type::Symbol) { return expressionForActualSymbol(symbol, r); } diff --git a/apps/shared/storage_expression_model.cpp b/apps/shared/storage_expression_model.cpp index 8fe4477e4..928c22e24 100644 --- a/apps/shared/storage_expression_model.cpp +++ b/apps/shared/storage_expression_model.cpp @@ -40,7 +40,7 @@ void StorageExpressionModel::text(char * buffer, size_t bufferSize) const { } Expression StorageExpressionModel::expression() const { - if (m_expression.isUninitialized()) { + if (m_expression.isUninitialized() && !m_record.isNull()) { m_expression = Expression::ExpressionFromAddress(expressionAddress(), expressionSize()); } return m_expression; @@ -51,7 +51,7 @@ Expression StorageExpressionModel::reducedExpression(Poincare::Context * context } Layout StorageExpressionModel::layout() { - if (m_layout.isUninitialized()) { + if (m_layout.isUninitialized() && !m_record.isNull()) { m_layout = PoincareHelpers::CreateLayout(expression()); if (m_layout.isUninitialized()) { m_layout = HorizontalLayout(); diff --git a/ion/src/shared/storage.cpp b/ion/src/shared/storage.cpp index 2bb28236c..da736cc1d 100644 --- a/ion/src/shared/storage.cpp +++ b/ion/src/shared/storage.cpp @@ -414,6 +414,9 @@ bool Storage::FullNameCompliant(const char * fullName) { } bool Storage::FullNameHasExtension(const char * fullName, const char * extension, size_t extensionLength) { + if (fullName == nullptr) { + return false; + } size_t fullNameLength = strlen(fullName); if (fullNameLength > extensionLength) { const char * ext = fullName + fullNameLength - extensionLength;