diff options
author | Zoltan Varga <vargaz@gmail.com> | 2010-04-14 01:40:26 +0400 |
---|---|---|
committer | Zoltan Varga <vargaz@gmail.com> | 2010-04-14 01:40:26 +0400 |
commit | 8089e2c37e4d841825f56e2f01d5735563001cff (patch) | |
tree | 9ec76b77f56f509e0ef324ec036b6fb64f6a613e /mcs | |
parent | dcb44d84c5cd6c241124c12b683a3496c14b8d59 (diff) |
2010-04-13 Zoltan Varga <vargaz@gmail.com>
* Convert.cs (ToInt32): Do a checked cast. Fixes #596339.
svn path=/branches/mono-2-6/mcs/; revision=155335
Diffstat (limited to 'mcs')
-rw-r--r-- | mcs/class/corlib/System/ChangeLog | 4 | ||||
-rw-r--r-- | mcs/class/corlib/System/Convert.cs | 8 |
2 files changed, 10 insertions, 2 deletions
diff --git a/mcs/class/corlib/System/ChangeLog b/mcs/class/corlib/System/ChangeLog index e9d254e9b4e..2a90ec7b64a 100644 --- a/mcs/class/corlib/System/ChangeLog +++ b/mcs/class/corlib/System/ChangeLog @@ -1,3 +1,7 @@ +2010-04-13 Zoltan Varga <vargaz@gmail.com> + + * Convert.cs (ToInt32): Do a checked cast. Fixes #596339. + 2009-11-17 Atsushi Enomoto <atsushi@ximian.com> * DateTimeOffset.cs : fix parse failure on missing colon. diff --git a/mcs/class/corlib/System/Convert.cs b/mcs/class/corlib/System/Convert.cs index 9cb28d656d0..1dad5c4fc92 100644 --- a/mcs/class/corlib/System/Convert.cs +++ b/mcs/class/corlib/System/Convert.cs @@ -1220,7 +1220,9 @@ namespace System { "Value is greater than Int32.MaxValue or less than Int32.MinValue")); // Returned Even-Rounded - return (int)(Math.Round (value)); + checked { + return (int)(Math.Round (value)); + } } public static int ToInt32 (float value) @@ -1231,7 +1233,9 @@ namespace System { // Returned Even-Rounded, pass as a double, could just call // Convert.ToInt32 ( (double)value); - return (int)(Math.Round ( (double)value)); + checked { + return (int)(Math.Round ( (double)value)); + } } public static int ToInt32 (int value) |