Skip to content

Commit 8e894e2

Browse files
committed
SSLSocket#sysread do not copy bytes from buffer - instead re-use the backing array
1 parent 2ef7b9c commit 8e894e2

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/main/java/org/jruby/ext/openssl/SSLSocket.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -757,10 +757,9 @@ private IRubyObject sysreadImpl(final ThreadContext context,
757757
if ( ex instanceof IRubyObject ) return (IRubyObject) ex; // :wait_readable
758758
}
759759
}
760-
byte[] bytesRead = new byte[read];
761-
dst.position(dst.position() - read);
762-
dst.get(bytesRead);
763-
buffStr.setValue(new ByteList(bytesRead, false));
760+
final byte[] bytesRead = dst.array();
761+
final int offset = dst.position() - read;
762+
buffStr.setValue(new ByteList(bytesRead, offset, read, false));
764763
return buffStr;
765764
}
766765
catch (IOException ioe) {

0 commit comments

Comments
 (0)