Update ByteBuffer.position() one last time before returning from Serialize.read().
This commit is contained in:
parent
755844c81a
commit
2127084a53
2 changed files with 5 additions and 1 deletions
|
@ -462,4 +462,4 @@ struct TestConstants {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const globalInt :UInt32 = 12345;
|
const globalInt :UInt32 = 12345;
|
||||||
|
|
|
@ -111,6 +111,9 @@ public final class Serialize {
|
||||||
return read(bb, ReaderOptions.DEFAULT_READER_OPTIONS);
|
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 {
|
public static MessageReader read(ByteBuffer bb, ReaderOptions options) throws IOException {
|
||||||
bb.order(ByteOrder.LITTLE_ENDIAN);
|
bb.order(ByteOrder.LITTLE_ENDIAN);
|
||||||
|
|
||||||
|
@ -139,6 +142,7 @@ public final class Serialize {
|
||||||
|
|
||||||
totalWords += segmentSize;
|
totalWords += segmentSize;
|
||||||
}
|
}
|
||||||
|
bb.position(segmentBase + totalWords * Constants.BYTES_PER_WORD);
|
||||||
|
|
||||||
if (totalWords > options.traversalLimitInWords) {
|
if (totalWords > options.traversalLimitInWords) {
|
||||||
throw new DecodeException("Message size exceeds traversal limit.");
|
throw new DecodeException("Message size exceeds traversal limit.");
|
||||||
|
|
Loading…
Reference in a new issue