aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2017-02-02 08:24:45 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2017-02-02 08:24:45 +0800
commit697db80b48fbed596996a2dab20948f42fdb1dfb (patch)
treed0e0226662467b5c4c9243943bbf86054ca81352 /libsolidity
parentc01f5699e673f600fe87056b414996fef2224242 (diff)
downloaddexon-solidity-697db80b48fbed596996a2dab20948f42fdb1dfb.tar.gz
dexon-solidity-697db80b48fbed596996a2dab20948f42fdb1dfb.tar.zst
dexon-solidity-697db80b48fbed596996a2dab20948f42fdb1dfb.zip
Disallow arrays with negative length
Diffstat (limited to 'libsolidity')
-rw-r--r--libsolidity/analysis/ReferencesResolver.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/libsolidity/analysis/ReferencesResolver.cpp b/libsolidity/analysis/ReferencesResolver.cpp
index df579c3d..d589f4a0 100644
--- a/libsolidity/analysis/ReferencesResolver.cpp
+++ b/libsolidity/analysis/ReferencesResolver.cpp
@@ -130,6 +130,8 @@ void ReferencesResolver::endVisit(ArrayTypeName const& _typeName)
auto const* lengthType = dynamic_cast<RationalNumberType const*>(length->annotation().type.get());
if (!lengthType || lengthType->isFractional())
fatalTypeError(length->location(), "Invalid array length, expected integer literal.");
+ else if (lengthType->isNegative())
+ fatalTypeError(length->location(), "Array with negative length specified.");
else
_typeName.annotation().type = make_shared<ArrayType>(DataLocation::Storage, baseType, lengthType->literalValue(nullptr));
}