Explorar o código

Only write to the read buffer if we actually received data.

Gert Driesen %!s(int64=8) %!d(string=hai) anos
pai
achega
4e2bd63660
Modificáronse 1 ficheiros con 2 adicións e 2 borrados
  1. 2 2
      src/Renci.SshNet/Sftp/SftpFileStream.cs

+ 2 - 2
src/Renci.SshNet/Sftp/SftpFileStream.cs

@@ -337,14 +337,14 @@ namespace Renci.SshNet.Sftp
                         var data = _session.RequestRead(_handle, (ulong)_position, (uint)_readBufferSize);
 
                         _bufferLen = data.Length;
-
-                        Buffer.BlockCopy(data, 0, _readBuffer, 0, _bufferLen);
                         _serverFilePosition = (ulong)_position;
 
                         if (_bufferLen == 0)
                         {
                             break;
                         }
+
+                        Buffer.BlockCopy(data, 0, _readBuffer, 0, _bufferLen);
                         tempLen = _bufferLen;
                     }