diff options
author | chriseth <chris@ethereum.org> | 2018-02-15 21:57:09 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-15 21:57:09 +0800 |
commit | f4aa05f308ef6b738e94e400b1cfcfb49b3bf5d6 (patch) | |
tree | eb5d78372cd7f849d7a6a2bc49cbb1280bf78ecc /libsolidity/codegen | |
parent | 5746e2d7d867440780ced524dd7e7c29149cf3e2 (diff) | |
parent | 2b5a5a8669cee8698f3f2cf970417a7123fbbe25 (diff) | |
download | dexon-solidity-f4aa05f308ef6b738e94e400b1cfcfb49b3bf5d6.tar.gz dexon-solidity-f4aa05f308ef6b738e94e400b1cfcfb49b3bf5d6.tar.zst dexon-solidity-f4aa05f308ef6b738e94e400b1cfcfb49b3bf5d6.zip |
Merge pull request #3523 from ethereum/throwMulmod
Make addmod and mulmod revert if the last argument is zero.
Diffstat (limited to 'libsolidity/codegen')
-rw-r--r-- | libsolidity/codegen/ExpressionCompiler.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp index 8e1cf019..61920592 100644 --- a/libsolidity/codegen/ExpressionCompiler.cpp +++ b/libsolidity/codegen/ExpressionCompiler.cpp @@ -765,7 +765,11 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall) case FunctionType::Kind::AddMod: case FunctionType::Kind::MulMod: { - for (unsigned i = 0; i < 3; i ++) + arguments[2]->accept(*this); + utils().convertType(*arguments[2]->annotation().type, IntegerType(256)); + m_context << Instruction::DUP1 << Instruction::ISZERO; + m_context.appendConditionalInvalid(); + for (unsigned i = 1; i < 3; i ++) { arguments[2 - i]->accept(*this); utils().convertType(*arguments[2 - i]->annotation().type, IntegerType(256)); |