Przeglądaj źródła

2008-05-05 Zoltan Varga <[email protected]>

	* FieldInfo.cs (GetFieldFromHandle): Add an argument check for an invalid handle.

	* MethodBase.cs (GetMethodFromHandle): Ditto. Fixes #386641.

svn path=/trunk/mcs/; revision=102529
Zoltan Varga 17 lat temu
rodzic
commit
8424d00a70

+ 6 - 0
mcs/class/corlib/System.Reflection/ChangeLog

@@ -1,3 +1,9 @@
+2008-05-05  Zoltan Varga  <[email protected]>
+
+	* FieldInfo.cs (GetFieldFromHandle): Add an argument check for an invalid handle.
+
+	* MethodBase.cs (GetMethodFromHandle): Ditto. Fixes #386641.
+
 2008-04-30  Gert Driesen  <[email protected]>
 2008-04-30  Gert Driesen  <[email protected]>
 
 
 	* ParameterInfo.cs: Name must default to null if no ParameterBuilder
 	* ParameterInfo.cs: Name must default to null if no ParameterBuilder

+ 4 - 0
mcs/class/corlib/System.Reflection/FieldInfo.cs

@@ -153,6 +153,8 @@ namespace System.Reflection {
 
 
 		public static FieldInfo GetFieldFromHandle (RuntimeFieldHandle handle)
 		public static FieldInfo GetFieldFromHandle (RuntimeFieldHandle handle)
 		{
 		{
+			if (handle.Value == IntPtr.Zero)
+				throw new ArgumentException ("The handle is invalid.");
 			return internal_from_handle_type (handle.Value, IntPtr.Zero);
 			return internal_from_handle_type (handle.Value, IntPtr.Zero);
 		}
 		}
 
 
@@ -160,6 +162,8 @@ namespace System.Reflection {
 		[ComVisible (false)]
 		[ComVisible (false)]
 		public static FieldInfo GetFieldFromHandle (RuntimeFieldHandle handle, RuntimeTypeHandle declaringType)
 		public static FieldInfo GetFieldFromHandle (RuntimeFieldHandle handle, RuntimeTypeHandle declaringType)
 		{
 		{
+			if (handle.Value == IntPtr.Zero)
+				throw new ArgumentException ("The handle is invalid.");
 			return internal_from_handle_type (handle.Value, declaringType.Value);
 			return internal_from_handle_type (handle.Value, declaringType.Value);
 		}
 		}
 #endif
 #endif

+ 4 - 0
mcs/class/corlib/System.Reflection/MethodBase.cs

@@ -47,6 +47,8 @@ namespace System.Reflection {
 		public extern static MethodBase GetCurrentMethod ();
 		public extern static MethodBase GetCurrentMethod ();
 
 
 		public static MethodBase GetMethodFromHandle(RuntimeMethodHandle handle) {
 		public static MethodBase GetMethodFromHandle(RuntimeMethodHandle handle) {
+			if (handle.Value == IntPtr.Zero)
+				throw new ArgumentException ("The handle is invalid.");
 			return GetMethodFromHandleInternalType (handle.Value, IntPtr.Zero);
 			return GetMethodFromHandleInternalType (handle.Value, IntPtr.Zero);
 		}
 		}
 
 
@@ -56,6 +58,8 @@ namespace System.Reflection {
 #if NET_2_0
 #if NET_2_0
 		[ComVisible (false)]
 		[ComVisible (false)]
 		public static MethodBase GetMethodFromHandle(RuntimeMethodHandle handle, RuntimeTypeHandle declaringType) {
 		public static MethodBase GetMethodFromHandle(RuntimeMethodHandle handle, RuntimeTypeHandle declaringType) {
+			if (handle.Value == IntPtr.Zero)
+				throw new ArgumentException ("The handle is invalid.");
 			return GetMethodFromHandleInternalType (handle.Value, declaringType.Value);
 			return GetMethodFromHandleInternalType (handle.Value, declaringType.Value);
 		}
 		}
 #endif
 #endif