Restrict size for dynamic memory array creation.

This commit is contained in:
Daniel Kirchner
2020-04-01 17:25:09 +02:00
parent fb7f51ffca
commit fe9f8d520c
3 changed files with 34 additions and 0 deletions
@@ -995,6 +995,12 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall)
// Fetch requested length.
acceptAndConvert(*arguments[0], *TypeProvider::uint256());
// Make sure we can allocate memory without overflow
m_context << u256(0xffffffffffffffff);
m_context << Instruction::DUP2;
m_context << Instruction::GT;
m_context.appendConditionalRevert();
// Stack: requested_length
utils().fetchFreeMemoryPointer();