From ff5be1799088ca51fb51e9c86031bd2d88fe3bce Mon Sep 17 00:00:00 2001 From: Erik Kundt Date: Fri, 21 Sep 2018 18:26:19 +0200 Subject: Disallows fixed-size multidim. arrays with zero-length. --- libsolidity/analysis/TypeChecker.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'libsolidity') diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index 3056561b..3b5e7b11 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -822,12 +822,17 @@ bool TypeChecker::visit(VariableDeclaration const& _variable) { case Type::Category::Array: if (auto arrayType = dynamic_cast(varType.get())) + { if ( ((arrayType->location() == DataLocation::Memory) || (arrayType->location() == DataLocation::CallData)) && !arrayType->validForCalldata() ) m_errorReporter.typeError(_variable.location(), "Array is too large to be encoded."); + if (auto baseType = dynamic_cast(arrayType->baseType().get())) + if (!baseType->isDynamicallySized() && baseType->length() == 0) + m_errorReporter.typeError(_variable.location(), "Fixed-size multidimensional arrays are not allowed to have zero length."); + } break; case Type::Category::Mapping: if (auto mappingType = dynamic_cast(varType.get())) -- cgit