Merge pull request #6261 from ethereum/padContractName

Defensively pad memory for ``type(C).name`` to multiples of 32.
This commit is contained in:
chriseth
2019-03-13 19:52:18 +01:00
committed by GitHub
2 changed files with 2 additions and 1 deletions
+1
View File
@@ -7,6 +7,7 @@ Compiler Features:
Bugfixes:
* Code Generator: Defensively pad memory for ``type(Contract).name`` to multiples of 32.
Build System:
+1 -1
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