Browse Source

Interpret the second argument as byte number, not bit number.

cl-refactor
Christian 10 years ago
parent
commit
20ce32d4dc
  1. 8
      libevm/VM.h

8
libevm/VM.h

@ -422,12 +422,12 @@ template <class Ext> dev::bytesConstRef dev::eth::VM::go(Ext& _ext, OnOpFunc con
m_stack.pop_back(); m_stack.pop_back();
break; break;
case Instruction::SIGNEXTEND: case Instruction::SIGNEXTEND:
if (m_stack.back() < 255) if (m_stack.back() < 31)
{ {
unsigned const bit(m_stack.back()); unsigned const testBit(m_stack.back() * 8 + 7);
u256& number = m_stack[m_stack.size() - 2]; u256& number = m_stack[m_stack.size() - 2];
u256 mask = ((u256(1) << bit) - 1); u256 mask = ((u256(1) << testBit) - 1);
if (boost::multiprecision::bit_test(number, bit)) if (boost::multiprecision::bit_test(number, testBit))
number |= ~mask; number |= ~mask;
else else
number &= mask; number &= mask;

Loading…
Cancel
Save