Skip to content

Commit d200db6

Browse files
committed
Need to copy bytes out of ByteBuffer, not reference internal array.
1 parent 740fa0c commit d200db6

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/vm/jvm/runtime/org/perl6/nqp/io/AsyncSocketHandle.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,9 @@ public void readBytes(final ThreadContext tc, final AsyncTaskInstance task, fina
164164
public SixModelObject decode(ThreadContext tc, ByteBuffer source, Integer numRead)
165165
throws Exception {
166166
SixModelObject res = bufType.st.REPR.allocate(tc, bufType.st);
167-
Buffers.stashBytes(tc, res, source.slice().array());
167+
byte[] bytes = new byte[source.remaining()];
168+
source.get(bytes);
169+
Buffers.stashBytes(tc, res, bytes);
168170
return res;
169171
}
170172
});

0 commit comments

Comments
 (0)