Skip to content

Commit c9bfede

Browse files
committedJan 24, 2018
Don't view the same buffer; it might be updated while in use.
Due to a bug in how Enumerator#next progresses (it will run an iteration ahead of requested) this bug was exposed as #4903 where an Enumerator#next-based sink for IO.copy_stream showed previously-returned results getting modified after handoff. The same buffer array was being shared across all chunks written, which works ok if that view were only used within the confines of copy_stream, but in this case the chunks were held across more than a single write. Fixes #4903. See #5007 for the Enumerator#next bug.
1 parent cce8776 commit c9bfede

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed
 

‎core/src/main/java/org/jruby/util/IOChannel.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ protected int write(CallSite write, ByteBuffer src) throws IOException {
9797
ByteList buffer;
9898

9999
if (src.hasArray()) {
100-
buffer = new ByteList(src.array(), src.position(), src.remaining(), false);
100+
buffer = new ByteList(src.array(), src.position(), src.remaining(), true);
101101
} else {
102102
buffer = new ByteList(src.remaining());
103103
buffer.append(src, src.remaining());

0 commit comments

Comments
 (0)
Please sign in to comment.