Skip to content

Commit 4e2bd63

Browse files
committed
Only write to the read buffer if we actually received data.
1 parent 391a41c commit 4e2bd63

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Renci.SshNet/Sftp/SftpFileStream.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,14 +337,14 @@ public override int Read(byte[] buffer, int offset, int count)
337337
var data = _session.RequestRead(_handle, (ulong)_position, (uint)_readBufferSize);
338338

339339
_bufferLen = data.Length;
340-
341-
Buffer.BlockCopy(data, 0, _readBuffer, 0, _bufferLen);
342340
_serverFilePosition = (ulong)_position;
343341

344342
if (_bufferLen == 0)
345343
{
346344
break;
347345
}
346+
347+
Buffer.BlockCopy(data, 0, _readBuffer, 0, _bufferLen);
348348
tempLen = _bufferLen;
349349
}
350350

0 commit comments

Comments
 (0)