Make function calls throw if target does not have code.

Low-level calls still just execute and will actually report "success".
This allows `x.call.value(y)()` for x being a non-contract account.
This commit is contained in:
chriseth
2016-08-17 11:30:40 +02:00
parent e7683f4722
commit 774bb8ab3b
3 changed files with 37 additions and 0 deletions
@@ -1517,6 +1517,13 @@ void ExpressionCompiler::appendExternalFunctionCall(
m_context << u256(0);
m_context << dupInstruction(m_context.baseToCurrentStackOffset(contractStackPos));
// Check the the target contract exists (has code) for non-low-level calls.
if (funKind == FunctionKind::External || funKind == FunctionKind::CallCode || funKind == FunctionKind::DelegateCall)
{
m_context << Instruction::DUP1 << Instruction::EXTCODESIZE << Instruction::ISZERO;
m_context.appendConditionalJumpTo(m_context.errorTag());
}
if (_functionType.gasSet())
m_context << dupInstruction(m_context.baseToCurrentStackOffset(gasStackPos));
else