[corlib] Fix Convert.ToUInt32 not throwing OverflowException with a too large number
[mono.git] / mcs / class / corlib / ReferenceSources / ParseNumbers.cs
index c87ea8f0860935c6a89c82a73368cb2dda6d5f73..9ab569e9330ac4bb2cfbfb99cfbc77e4d1d81985 100644 (file)
@@ -122,11 +122,11 @@ namespace System {
                                        throw new FormatException ("Could not find any parsable digits.");
                                }
 
-                               var res = (uint) fromBase * result + (uint) digitValue;
-                               if (res < result || res > max_value)
+                               long res = fromBase * result + digitValue;
+                               if (res > max_value)
                                        throw new OverflowException ();
                                        
-                               result = res;
+                               result = (uint)res;
                                chars++;
                                ++i;
                        }