Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGonzalo Paniagua Javier <gonzalo.mono@gmail.com>2011-03-09 02:05:15 +0300
committerGonzalo Paniagua Javier <gonzalo.mono@gmail.com>2011-03-09 02:05:46 +0300
commit1e7c592026736104bfbb33840b899550584df16c (patch)
tree7d363dfd8c2b2f61da1ca3eab57959e62c23a8c1 /mcs/class/corlib/System.IO/MemoryStream.cs
parent4a7c594eb1c6e9aaf08a887908a33cc289bfe882 (diff)
Avoid null refs when capacity set to 0
This fixes bug #676060.
Diffstat (limited to 'mcs/class/corlib/System.IO/MemoryStream.cs')
-rw-r--r--mcs/class/corlib/System.IO/MemoryStream.cs5
1 files changed, 3 insertions, 2 deletions
diff --git a/mcs/class/corlib/System.IO/MemoryStream.cs b/mcs/class/corlib/System.IO/MemoryStream.cs
index 45673b328e6..ca74ff4087e 100644
--- a/mcs/class/corlib/System.IO/MemoryStream.cs
+++ b/mcs/class/corlib/System.IO/MemoryStream.cs
@@ -163,13 +163,14 @@ namespace System.IO
throw new ArgumentOutOfRangeException ("value",
"New capacity cannot be negative or less than the current capacity " + value + " " + capacity);
- if (value == internalBuffer.Length)
+ if (internalBuffer != null && value == internalBuffer.Length)
return;
byte [] newBuffer = null;
if (value != 0) {
newBuffer = new byte [value];
- Buffer.BlockCopy (internalBuffer, 0, newBuffer, 0, length);
+ if (internalBuffer != null)
+ Buffer.BlockCopy (internalBuffer, 0, newBuffer, 0, length);
}
dirty_bytes = 0; // discard any dirty area beyond previous length