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);
|
encodingType = encodingType->interfaceType(_inLibraryCall);
|
||||||
if (encodingType)
|
if (encodingType)
|
||||||
encodingType = encodingType->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,
|
||||||
// Structs are fine in the following circumstances:
|
// - storage struct for a library
|
||||||
// - ABIv2 without packed encoding or,
|
if (_inLibraryCall && encodingType->dataStoredIn(DataLocation::Storage))
|
||||||
// - storage struct for a library
|
return encodingType;
|
||||||
if (!(
|
TypePointer baseType = encodingType;
|
||||||
(_encoderV2 && !_packed) ||
|
while (auto const* arrayType = dynamic_cast<ArrayType const*>(baseType.get()))
|
||||||
(structType->location() == DataLocation::Storage && _inLibraryCall)
|
baseType = arrayType->baseType();
|
||||||
))
|
if (dynamic_cast<StructType const*>(baseType.get()))
|
||||||
|
if (!_encoderV2 || _packed)
|
||||||
return TypePointer();
|
return TypePointer();
|
||||||
}
|
|
||||||
return encodingType;
|
return encodingType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user