aboutsummaryrefslogtreecommitdiffstats
path: root/liblll/CodeFragment.cpp
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-11-13 21:10:48 +0800
committerGitHub <noreply@github.com>2018-11-13 21:10:48 +0800
commitc237013911aa5bb6102e1262e6aa62178c0f02e0 (patch)
tree2827f17d04ed01a3e36a2fed83cbd9e8b2a2003b /liblll/CodeFragment.cpp
parent82fadfd1a7c5715595ddbf6643ae494cdb6eca8c (diff)
parent90e4d244073c1d9ced47711a533cc8fe4ac217f2 (diff)
downloaddexon-solidity-c237013911aa5bb6102e1262e6aa62178c0f02e0.tar
dexon-solidity-c237013911aa5bb6102e1262e6aa62178c0f02e0.tar.gz
dexon-solidity-c237013911aa5bb6102e1262e6aa62178c0f02e0.tar.bz2
dexon-solidity-c237013911aa5bb6102e1262e6aa62178c0f02e0.tar.lz
dexon-solidity-c237013911aa5bb6102e1262e6aa62178c0f02e0.tar.xz
dexon-solidity-c237013911aa5bb6102e1262e6aa62178c0f02e0.tar.zst
dexon-solidity-c237013911aa5bb6102e1262e6aa62178c0f02e0.zip
Merge pull request #5020 from ethereum/lll-seq-fix
LLL: terminate sequences with a STOP
Diffstat (limited to 'liblll/CodeFragment.cpp')
-rw-r--r--liblll/CodeFragment.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/liblll/CodeFragment.cpp b/liblll/CodeFragment.cpp
index 85480119..f37cb8b9 100644
--- a/liblll/CodeFragment.cpp
+++ b/liblll/CodeFragment.cpp
@@ -45,6 +45,10 @@ using namespace dev::lll;
void CodeFragment::finalise(CompilerState const& _cs)
{
+ // NOTE: add this as a safeguard in case the user didn't issue an
+ // explicit stop at the end of the sequence
+ m_asm.append(Instruction::STOP);
+
if (_cs.usedAlloc && _cs.vars.size() && !m_finalised)
{
m_finalised = true;
@@ -232,7 +236,12 @@ void CodeFragment::constructOperation(sp::utree const& _t, CompilerState& _s)
int c = 0;
for (auto const& i: _t)
if (c++)
- m_asm.append(CodeFragment(i, _s, m_readFile, true).m_asm);
+ {
+ auto fragment = CodeFragment(i, _s, m_readFile, true).m_asm;
+ if ((m_asm.deposit() + fragment.deposit()) < 0)
+ error<IncorrectParameterCount>("The assembly instruction resulted in stack underflow");
+ m_asm.append(fragment);
+ }
}
else if (us == "INCLUDE")
{