Skip to content

Commit

Permalink
Only get new data from readBuffer
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
usev6 committed May 16, 2016
1 parent 1adeaba commit 43e3696
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/vm/jvm/runtime/org/perl6/nqp/io/SyncHandle.java
Expand Up @@ -59,7 +59,9 @@ public synchronized String slurp(ThreadContext tc) {
int read;
if (readBuffer != null) {
total = readBuffer.limit() - readBuffer.position();
buffers.add(ByteBuffer.wrap(readBuffer.array(), readBuffer.position(), total));
byte[] newBytes = new byte[total];
readBuffer.get(newBytes);
buffers.add(ByteBuffer.wrap(newBytes));
readBuffer = null;
}
while ((read = chan.read(curBuffer)) != -1) {
Expand Down

0 comments on commit 43e3696

Please sign in to comment.