Selaa lähdekoodia

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

Gert Driesen 8 vuotta sitten
vanhempi
sitoutus
4e2bd63660
1 muutettua tiedostoa jossa 2 lisäystä ja 2 poistoa
  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;
                     }