Sfoglia il codice sorgente

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

Gert Driesen 8 anni fa
parent
commit
4e2bd63660
1 ha cambiato i file con 2 aggiunte e 2 eliminazioni
  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;
                     }