Skip to content

Commit 43e3696

Browse files
committed
Only get new data from readBuffer
While using nqp::readallfh after a call to nqp::readlinechompfh there seemed to be old data in readBuffer -- and we copied that instead of only new data.
1 parent 1adeaba commit 43e3696

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ public synchronized String slurp(ThreadContext tc) {
5959
int read;
6060
if (readBuffer != null) {
6161
total = readBuffer.limit() - readBuffer.position();
62-
buffers.add(ByteBuffer.wrap(readBuffer.array(), readBuffer.position(), total));
62+
byte[] newBytes = new byte[total];
63+
readBuffer.get(newBytes);
64+
buffers.add(ByteBuffer.wrap(newBytes));
6365
readBuffer = null;
6466
}
6567
while ((read = chan.read(curBuffer)) != -1) {

0 commit comments

Comments
 (0)