Skip to content

Commit

Permalink
fix copying to not overwrite before offset
Browse files Browse the repository at this point in the history
  • Loading branch information
stepeos authored and dwrensha committed Oct 22, 2024
1 parent c9e4512 commit 08009f3
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions runtime/src/main/java/org/capnproto/WireHelpers.java
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,14 @@ static Data.Builder setDataPointer(int refOffset,
SegmentBuilder segment,
Data.Reader value) {
Data.Builder builder = initDataPointer(refOffset, segment, value.size);
int originalSrcPosition = value.buffer.position();
int originalDstPosition = builder.buffer.position();
builder.buffer.position(builder.offset);
//# copy from src offset until src end
builder.buffer.put(value.buffer);
//# restore original positions
builder.buffer.position(originalDstPosition);
value.buffer.position(originalSrcPosition);
return builder;
}

Expand Down

0 comments on commit 08009f3

Please sign in to comment.