Update ByteBuffer.position() one last time before returning from Serialize.read().

This commit is contained in:
David Renshaw 2015-08-17 22:13:06 -04:00
parent 755844c81a
commit 2127084a53
2 changed files with 5 additions and 1 deletions

View file

@ -111,6 +111,9 @@ public final class Serialize {
return read(bb, ReaderOptions.DEFAULT_READER_OPTIONS);
}
/*
* Upon return, `bb.position()` we be at the end of the message.
*/
public static MessageReader read(ByteBuffer bb, ReaderOptions options) throws IOException {
bb.order(ByteOrder.LITTLE_ENDIAN);
@ -139,6 +142,7 @@ public final class Serialize {
totalWords += segmentSize;
}
bb.position(segmentBase + totalWords * Constants.BYTES_PER_WORD);
if (totalWords > options.traversalLimitInWords) {
throw new DecodeException("Message size exceeds traversal limit.");