aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2016-08-17 22:44:15 +0800
committerGitHub <noreply@github.com>2016-08-17 22:44:15 +0800
commitb2507e9f105ab701c417f8f2d125edf8f3022698 (patch)
treee67c6047c68d8e89e218fcb5dec1ef394aa4b828 /libsolidity
parentd6579a0a5f99425eae95329b77e07ea072122924 (diff)
parent774bb8ab3baa9d7b5e6368dcd0f887b13ff26ae8 (diff)
downloaddexon-solidity-b2507e9f105ab701c417f8f2d125edf8f3022698.tar
dexon-solidity-b2507e9f105ab701c417f8f2d125edf8f3022698.tar.gz
dexon-solidity-b2507e9f105ab701c417f8f2d125edf8f3022698.tar.bz2
dexon-solidity-b2507e9f105ab701c417f8f2d125edf8f3022698.tar.lz
dexon-solidity-b2507e9f105ab701c417f8f2d125edf8f3022698.tar.xz
dexon-solidity-b2507e9f105ab701c417f8f2d125edf8f3022698.tar.zst
dexon-solidity-b2507e9f105ab701c417f8f2d125edf8f3022698.zip
Merge pull request #839 from chriseth/checkcode
BREAKING: Make function calls throw if target does not have code.
Diffstat (limited to 'libsolidity')
-rw-r--r--libsolidity/codegen/ExpressionCompiler.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp
index 4695ff96..4a81e27d 100644
--- a/libsolidity/codegen/ExpressionCompiler.cpp
+++ b/libsolidity/codegen/ExpressionCompiler.cpp
@@ -1524,6 +1524,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