diff --git a/compiler/src/test/schema/test.capnp b/compiler/src/test/schema/test.capnp index b8ebc1f..6fabea9 100644 --- a/compiler/src/test/schema/test.capnp +++ b/compiler/src/test/schema/test.capnp @@ -462,4 +462,4 @@ struct TestConstants { } -const globalInt :UInt32 = 12345; \ No newline at end of file +const globalInt :UInt32 = 12345; diff --git a/runtime/src/main/java/org/capnproto/Serialize.java b/runtime/src/main/java/org/capnproto/Serialize.java index 6a53553..6aca38b 100644 --- a/runtime/src/main/java/org/capnproto/Serialize.java +++ b/runtime/src/main/java/org/capnproto/Serialize.java @@ -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.");