diff options
author | chriseth <c@ethdev.com> | 2016-09-05 21:47:03 +0800 |
---|---|---|
committer | Yoichi Hirai <i@yoichihirai.com> | 2016-09-06 18:37:01 +0800 |
commit | 9ca7472089a9f4d8bfec20e9e55c4f7ed2fb502e (patch) | |
tree | 02763f7df79f27cac82373f078d98ae76ab2155e /libsolidity/codegen | |
parent | f687635e4743a1e12d01fb082a4f8a76a759ab48 (diff) | |
download | dexon-solidity-9ca7472089a9f4d8bfec20e9e55c4f7ed2fb502e.tar dexon-solidity-9ca7472089a9f4d8bfec20e9e55c4f7ed2fb502e.tar.gz dexon-solidity-9ca7472089a9f4d8bfec20e9e55c4f7ed2fb502e.tar.bz2 dexon-solidity-9ca7472089a9f4d8bfec20e9e55c4f7ed2fb502e.tar.lz dexon-solidity-9ca7472089a9f4d8bfec20e9e55c4f7ed2fb502e.tar.xz dexon-solidity-9ca7472089a9f4d8bfec20e9e55c4f7ed2fb502e.tar.zst dexon-solidity-9ca7472089a9f4d8bfec20e9e55c4f7ed2fb502e.zip |
Provide gas stipend manually for send(0).
Diffstat (limited to 'libsolidity/codegen')
-rw-r--r-- | libsolidity/codegen/ExpressionCompiler.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp index 1cc4a50d..96ca4296 100644 --- a/libsolidity/codegen/ExpressionCompiler.cpp +++ b/libsolidity/codegen/ExpressionCompiler.cpp @@ -568,12 +568,17 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall) break; case Location::Send: _functionCall.expression().accept(*this); - m_context << u256(0); // do not send gas (there still is the stipend) + // Provide the gas stipend manually at first because we may send zero ether. + // Will be zeroed if we send more than zero ether. + m_context << u256(eth::GasCosts::callStipend); arguments.front()->accept(*this); utils().convertType( *arguments.front()->annotation().type, *function.parameterTypes().front(), true ); + // gas <- gas * !value + m_context << Instruction::SWAP1 << Instruction::DUP2; + m_context << Instruction::ISZERO << Instruction::MUL << Instruction::SWAP1; appendExternalFunctionCall( FunctionType( TypePointers{}, |