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:
authorCarlos Alberto Cortez <calberto.cortez@gmail.com>2007-07-02 05:40:00 +0400
committerCarlos Alberto Cortez <calberto.cortez@gmail.com>2007-07-02 05:40:00 +0400
commit5770c73a0aac703d9994897206523830878f7488 (patch)
treea92198c7d47d34c0412223bc5798bda5af6145e6 /mcs/class/System/System.IO.Ports/SerialPort.cs
parentb436d116ea5fb3c693494458e255570e07fab804 (diff)
2007-07-01 Carlos Alberto Cortez <calberto.cortez@gmail.com>
* SerialPort.cs: Don't throw ArgumentOutOfRangeException when the buffer has Length = 0 (and has the appropriate arguments). svn path=/trunk/mcs/; revision=81151
Diffstat (limited to 'mcs/class/System/System.IO.Ports/SerialPort.cs')
-rw-r--r--mcs/class/System/System.IO.Ports/SerialPort.cs13
1 files changed, 7 insertions, 6 deletions
diff --git a/mcs/class/System/System.IO.Ports/SerialPort.cs b/mcs/class/System/System.IO.Ports/SerialPort.cs
index 8a2f2b6db82..f25ec7f0d68 100644
--- a/mcs/class/System/System.IO.Ports/SerialPort.cs
+++ b/mcs/class/System/System.IO.Ports/SerialPort.cs
@@ -708,12 +708,13 @@ namespace System.IO.Ports
CheckOpen ();
if (buffer == null)
throw new ArgumentNullException ("buffer");
- if (offset < 0 || offset >= buffer.Length)
- throw new ArgumentOutOfRangeException ("offset");
- if (count < 0 || count > buffer.Length)
- throw new ArgumentOutOfRangeException ("count");
- if (count > buffer.Length - offset)
- throw new ArgumentException ("count > buffer.Length - offset");
+
+ if (offset < 0 || count < 0)
+ throw new ArgumentOutOfRangeException ();
+
+ if (buffer.Length - offset < count)
+ throw new ArgumentException ("offset+count",
+ "The size of the buffer is less than offset + count.");
byte [] bytes = encoding.GetBytes (buffer, offset, count);
stream.Write (bytes, 0, bytes.Length);