diff options
author | Christian <c@ethdev.com> | 2015-01-14 17:46:44 +0800 |
---|---|---|
committer | Christian <c@ethdev.com> | 2015-01-14 17:46:44 +0800 |
commit | 22f0a4fde1a641e36945c60c67d96559f7ab5981 (patch) | |
tree | 3dca28d8603944623f9ae4e5b8645da3a41d8a01 /ExpressionCompiler.cpp | |
parent | b440d7e321793e0b053d3b467934a45f880863e0 (diff) | |
download | dexon-solidity-22f0a4fde1a641e36945c60c67d96559f7ab5981.tar.gz dexon-solidity-22f0a4fde1a641e36945c60c67d96559f7ab5981.tar.zst dexon-solidity-22f0a4fde1a641e36945c60c67d96559f7ab5981.zip |
Use min gas for send().
Diffstat (limited to 'ExpressionCompiler.cpp')
-rw-r--r-- | ExpressionCompiler.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/ExpressionCompiler.cpp b/ExpressionCompiler.cpp index ff08a326..93645187 100644 --- a/ExpressionCompiler.cpp +++ b/ExpressionCompiler.cpp @@ -290,12 +290,13 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall) arguments.front()->accept(*this); break; case Location::SEND: - // TODO set gas to min _functionCall.getExpression().accept(*this); + m_context << u256(0); // 0 gas, we do not want to execute code arguments.front()->accept(*this); appendTypeConversion(*arguments.front()->getType(), *function.getParameterTypes().front(), true); - appendExternalFunctionCall(FunctionType(TypePointers{}, TypePointers{}, Location::EXTERNAL, false, true), {}, true); + appendExternalFunctionCall(FunctionType(TypePointers{}, TypePointers{}, + Location::EXTERNAL, true, true), {}, true); break; case Location::SUICIDE: arguments.front()->accept(*this); @@ -696,7 +697,8 @@ void ExpressionCompiler::appendExternalFunctionCall(FunctionType const& _functio if (_functionType.gasSet()) m_context << eth::dupInstruction(7 + (_functionType.valueSet() ? 1 : 0)); else - m_context << u256(25) << eth::Instruction::GAS << eth::Instruction::SUB; + // send all gas except for the 21 needed to execute "SUB" and "CALL" + m_context << u256(21) << eth::Instruction::GAS << eth::Instruction::SUB; m_context << eth::Instruction::CALL << eth::Instruction::POP; // @todo do not ignore failure indicator if (_functionType.valueSet()) |