mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Disallow packed encoding of arrays of structs.
This commit is contained in:
parent
6954f83a0c
commit
0b65b2dff6
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user