Browse Source

Stop on div by zero rather than throw.

cl-refactor
Gav Wood 11 years ago
parent
commit
dff8e9ef46
  1. 8
      libethereum/VM.h

8
libethereum/VM.h

@ -162,21 +162,29 @@ template <class Ext> void eth::VM::go(Ext& _ext, uint64_t _steps)
break; break;
case Instruction::DIV: case Instruction::DIV:
require(2); 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[m_stack.size() - 2] = m_stack.back() / m_stack[m_stack.size() - 2];
m_stack.pop_back(); m_stack.pop_back();
break; break;
case Instruction::SDIV: case Instruction::SDIV:
require(2); 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]; (s256&)m_stack[m_stack.size() - 2] = (s256&)m_stack.back() / (s256&)m_stack[m_stack.size() - 2];
m_stack.pop_back(); m_stack.pop_back();
break; break;
case Instruction::MOD: case Instruction::MOD:
require(2); 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[m_stack.size() - 2] = m_stack.back() % m_stack[m_stack.size() - 2];
m_stack.pop_back(); m_stack.pop_back();
break; break;
case Instruction::SMOD: case Instruction::SMOD:
require(2); 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]; (s256&)m_stack[m_stack.size() - 2] = (s256&)m_stack.back() % (s256&)m_stack[m_stack.size() - 2];
m_stack.pop_back(); m_stack.pop_back();
break; break;

Loading…
Cancel
Save