From dff8e9ef46a07091389e87ad3928605f0128333c Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Wed, 5 Mar 2014 10:52:07 -0600 Subject: [PATCH] Stop on div by zero rather than throw. --- libethereum/VM.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libethereum/VM.h b/libethereum/VM.h index caafc64b0..2f7d1fcaf 100644 --- a/libethereum/VM.h +++ b/libethereum/VM.h @@ -162,21 +162,29 @@ template void eth::VM::go(Ext& _ext, uint64_t _steps) break; case Instruction::DIV: require(2); + if (!m_stack[m_stack.size() - 2]) + return; m_stack[m_stack.size() - 2] = m_stack.back() / m_stack[m_stack.size() - 2]; m_stack.pop_back(); break; case Instruction::SDIV: require(2); + if (!m_stack[m_stack.size() - 2]) + return; (s256&)m_stack[m_stack.size() - 2] = (s256&)m_stack.back() / (s256&)m_stack[m_stack.size() - 2]; m_stack.pop_back(); break; case Instruction::MOD: require(2); + if (!m_stack[m_stack.size() - 2]) + return; m_stack[m_stack.size() - 2] = m_stack.back() % m_stack[m_stack.size() - 2]; m_stack.pop_back(); break; case Instruction::SMOD: require(2); + if (!m_stack[m_stack.size() - 2]) + return; (s256&)m_stack[m_stack.size() - 2] = (s256&)m_stack.back() % (s256&)m_stack[m_stack.size() - 2]; m_stack.pop_back(); break;