diff options
author | chriseth <chris@ethereum.org> | 2018-08-09 07:24:52 +0800 |
---|---|---|
committer | chriseth <chris@ethereum.org> | 2018-08-10 03:16:51 +0800 |
commit | 0b65b2dff64bdc6d71df94a13f89b7b1119b13b1 (patch) | |
tree | 814e5da84ba404314632d589dc31ef8ab54e918f /libsolidity/ast | |
parent | 6954f83a0c52d22ffae9bfbe24191547a7ef781f (diff) | |
download | dexon-solidity-0b65b2dff64bdc6d71df94a13f89b7b1119b13b1.tar.gz dexon-solidity-0b65b2dff64bdc6d71df94a13f89b7b1119b13b1.tar.zst dexon-solidity-0b65b2dff64bdc6d71df94a13f89b7b1119b13b1.zip |
Disallow packed encoding of arrays of structs.
Diffstat (limited to 'libsolidity/ast')
-rw-r--r-- | libsolidity/ast/Types.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp index 2dcfda42..5368e9c2 100644 --- a/libsolidity/ast/Types.cpp +++ b/libsolidity/ast/Types.cpp @@ -400,17 +400,17 @@ TypePointer Type::fullEncodingType(bool _inLibraryCall, bool _encoderV2, bool _p encodingType = encodingType->interfaceType(_inLibraryCall); if (encodingType) encodingType = encodingType->encodingType(); - if (auto structType = dynamic_cast<StructType const*>(encodingType.get())) - { - // Structs are fine in the following circumstances: - // - ABIv2 without packed encoding or, - // - storage struct for a library - if (!( - (_encoderV2 && !_packed) || - (structType->location() == DataLocation::Storage && _inLibraryCall) - )) + // Structs are fine in the following circumstances: + // - ABIv2 without packed encoding or, + // - storage struct for a library + if (_inLibraryCall && encodingType->dataStoredIn(DataLocation::Storage)) + return encodingType; + TypePointer baseType = encodingType; + while (auto const* arrayType = dynamic_cast<ArrayType const*>(baseType.get())) + baseType = arrayType->baseType(); + if (dynamic_cast<StructType const*>(baseType.get())) + if (!_encoderV2 || _packed) return TypePointer(); - } return encodingType; } |