diff --git a/src/main/java/org/jruby/ext/openssl/SSLSocket.java b/src/main/java/org/jruby/ext/openssl/SSLSocket.java index c4fa32b3..2346f975 100644 --- a/src/main/java/org/jruby/ext/openssl/SSLSocket.java +++ b/src/main/java/org/jruby/ext/openssl/SSLSocket.java @@ -757,10 +757,9 @@ private IRubyObject sysreadImpl(final ThreadContext context, if ( ex instanceof IRubyObject ) return (IRubyObject) ex; // :wait_readable } } - byte[] bytesRead = new byte[read]; - dst.position(dst.position() - read); - dst.get(bytesRead); - buffStr.setValue(new ByteList(bytesRead, false)); + final byte[] bytesRead = dst.array(); + final int offset = dst.position() - read; + buffStr.setValue(new ByteList(bytesRead, offset, read, false)); return buffStr; } catch (IOException ioe) {