2009-05-06 Lluis Sanchez Gual <lluis@novell.com>
[mono.git] / mcs / class / corlib / System.Security.Cryptography / CryptoStream.cs
index f87a1b1c4091c4a92f207ea6b49921f2e05252fe..9190921da57d3338c2ef4f645b34e17d55cd9ec7 100644 (file)
@@ -261,6 +261,8 @@ namespace System.Security.Cryptography {
                        if (_stream == null)
                                throw new ArgumentNullException ("inner stream was diposed");
 
+                       int buffer_length = count;
+
                        // partial block (in progress)
                        if ((_partialCount > 0) && (_partialCount != _transform.InputBlockSize)) {
                                int remainder = _transform.InputBlockSize - _partialCount;
@@ -297,7 +299,7 @@ namespace System.Security.Cryptography {
                                        }
 
                                        if (rem > 0)
-                                               Buffer.BlockCopy (buffer, buffer.Length - rem, _workingBlock, 0, rem);
+                                               Buffer.BlockCopy (buffer, buffer_length - rem, _workingBlock, 0, rem);
                                        _partialCount = rem;
                                        count = 0; // the last block, if any, is in _workingBlock
                                } else {