mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Use min gas for send().
This commit is contained in:
parent
b440d7e321
commit
22f0a4fde1
@ -290,12 +290,13 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall)
|
|||||||
arguments.front()->accept(*this);
|
arguments.front()->accept(*this);
|
||||||
break;
|
break;
|
||||||
case Location::SEND:
|
case Location::SEND:
|
||||||
// TODO set gas to min
|
|
||||||
_functionCall.getExpression().accept(*this);
|
_functionCall.getExpression().accept(*this);
|
||||||
|
m_context << u256(0); // 0 gas, we do not want to execute code
|
||||||
arguments.front()->accept(*this);
|
arguments.front()->accept(*this);
|
||||||
appendTypeConversion(*arguments.front()->getType(),
|
appendTypeConversion(*arguments.front()->getType(),
|
||||||
*function.getParameterTypes().front(), true);
|
*function.getParameterTypes().front(), true);
|
||||||
appendExternalFunctionCall(FunctionType(TypePointers{}, TypePointers{}, Location::EXTERNAL, false, true), {}, true);
|
appendExternalFunctionCall(FunctionType(TypePointers{}, TypePointers{},
|
||||||
|
Location::EXTERNAL, true, true), {}, true);
|
||||||
break;
|
break;
|
||||||
case Location::SUICIDE:
|
case Location::SUICIDE:
|
||||||
arguments.front()->accept(*this);
|
arguments.front()->accept(*this);
|
||||||
@ -696,7 +697,8 @@ void ExpressionCompiler::appendExternalFunctionCall(FunctionType const& _functio
|
|||||||
if (_functionType.gasSet())
|
if (_functionType.gasSet())
|
||||||
m_context << eth::dupInstruction(7 + (_functionType.valueSet() ? 1 : 0));
|
m_context << eth::dupInstruction(7 + (_functionType.valueSet() ? 1 : 0));
|
||||||
else
|
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
|
m_context << eth::Instruction::CALL
|
||||||
<< eth::Instruction::POP; // @todo do not ignore failure indicator
|
<< eth::Instruction::POP; // @todo do not ignore failure indicator
|
||||||
if (_functionType.valueSet())
|
if (_functionType.valueSet())
|
||||||
|
Loading…
Reference in New Issue
Block a user