diff --git a/src/main/java/com/esaulpaugh/headlong/rlp/RLPDecoder.java b/src/main/java/com/esaulpaugh/headlong/rlp/RLPDecoder.java index 5a31070f7..d2eafd16b 100644 --- a/src/main/java/com/esaulpaugh/headlong/rlp/RLPDecoder.java +++ b/src/main/java/com/esaulpaugh/headlong/rlp/RLPDecoder.java @@ -53,19 +53,19 @@ public Iterator sequenceIterator(byte[] buffer, int index) { @Override public boolean hasNext() { - if(next != null) { + if (next != null) { return true; } - if(index >= buffer.length) { - return false; - } - try { - next = decoder.wrap(buffer, index); - this.index = next.endIndex; - return true; - } catch (DecodeException de) { - throw noSuchElementException(de); + if (index < buffer.length) { + try { + next = decoder.wrap(buffer, index); + this.index = next.endIndex; + return true; + } catch (DecodeException de) { + throw noSuchElementException(de); + } } + return false; } }; }