Defensively pad memory for `type(C).name` to multiples of 32.

This commit is contained in:
chriseth 2019-03-13 14:27:25 +01:00
parent 2da906d901
commit 2e7794d8a6
2 changed files with 2 additions and 1 deletions

View File

@ -7,6 +7,7 @@ Compiler Features:
Bugfixes:
* Code Generator: Defensively pad memory for ``type(Contract).name`` to multiples of 32.
Build System:

View File

@ -1394,7 +1394,7 @@ bool ExpressionCompiler::visit(MemberAccess const& _memberAccess)
{
TypePointer arg = dynamic_cast<MagicType const&>(*_memberAccess.expression().annotation().type).typeArgument();
ContractDefinition const& contract = dynamic_cast<ContractType const&>(*arg).contractDefinition();
utils().allocateMemory(contract.name().length() + 32);
utils().allocateMemory(((contract.name().length() + 31) / 32) * 32 + 32);
// store string length
m_context << u256(contract.name().length()) << Instruction::DUP2 << Instruction::MSTORE;
// adjust pointer