Disallow packed encoding of arrays of structs.

This commit is contained in:
chriseth 2018-08-09 01:24:52 +02:00
parent 6954f83a0c
commit 0b65b2dff6

View File

@ -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;
} }