aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2016-09-06 21:37:05 +0800
committerGitHub <noreply@github.com>2016-09-06 21:37:05 +0800
commit5ade1bc20facd81f651548589a5e49ccfc71f14e (patch)
tree4ab9fa9f7133e558f425b993ac433048b61af4cd /libsolidity
parentafca2acb779746fc3ee12391137a133cbcec8d3b (diff)
parent9ca7472089a9f4d8bfec20e9e55c4f7ed2fb502e (diff)
downloaddexon-solidity-5ade1bc20facd81f651548589a5e49ccfc71f14e.tar.gz
dexon-solidity-5ade1bc20facd81f651548589a5e49ccfc71f14e.tar.zst
dexon-solidity-5ade1bc20facd81f651548589a5e49ccfc71f14e.zip
Merge pull request #1008 from ethereum/stipendwithsend
Provide gas stipend manually for send(0).
Diffstat (limited to 'libsolidity')
-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{},