Browse Source

2002-05-19 Martin Baulig <[email protected]>

	* Convert.cs (FromBase64CharArray): Do correct exception handling.

svn path=/trunk/mcs/; revision=4762
Martin Baulig 23 years ago
parent
commit
0442a5fa45
2 changed files with 6 additions and 3 deletions
  1. 4 0
      mcs/class/corlib/System/ChangeLog
  2. 2 3
      mcs/class/corlib/System/Convert.cs

+ 4 - 0
mcs/class/corlib/System/ChangeLog

@@ -1,3 +1,7 @@
+2002-05-19  Martin Baulig  <[email protected]>
+
+	* Convert.cs (FromBase64CharArray): Do correct exception handling.
+
 2002-05-19  Martin Baulig  <[email protected]>
 
 	* Convert.cs (FromBase64CharArray): Convert the char array using

+ 2 - 3
mcs/class/corlib/System/Convert.cs

@@ -94,11 +94,10 @@ namespace System {
 			if (inArray == null)
 				throw new ArgumentNullException();
 			
-			if ((offset < 0) || (offset + length > inArray.Length))
+			if ((offset < 0) || (length < 0) || (offset + length > inArray.Length))
 				throw new ArgumentOutOfRangeException();
 			
-			int len = inArray.Length;
-			if (len < 4 || len % 4 != 0)
+			if (length < 4 || length % 4 != 0)
 				throw new FormatException();
 				
 			byte[] inArr = new System.Text.UTF8Encoding().GetBytes(inArray, offset, length);