aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/codegen/ExpressionCompiler.cpp
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2016-09-05 21:47:03 +0800
committerYoichi Hirai <i@yoichihirai.com>2016-09-06 18:37:01 +0800
commit9ca7472089a9f4d8bfec20e9e55c4f7ed2fb502e (patch)
tree02763f7df79f27cac82373f078d98ae76ab2155e /libsolidity/codegen/ExpressionCompiler.cpp
parentf687635e4743a1e12d01fb082a4f8a76a759ab48 (diff)
downloaddexon-solidity-9ca7472089a9f4d8bfec20e9e55c4f7ed2fb502e.tar.gz
dexon-solidity-9ca7472089a9f4d8bfec20e9e55c4f7ed2fb502e.tar.zst
dexon-solidity-9ca7472089a9f4d8bfec20e9e55c4f7ed2fb502e.zip
Provide gas stipend manually for send(0).
Diffstat (limited to 'libsolidity/codegen/ExpressionCompiler.cpp')
-rw-r--r--libsolidity/codegen/ExpressionCompiler.cpp7
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{},