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:
authorAleksey Kliger <aleksey@xamarin.com>2017-10-10 02:15:41 +0300
committerMarek Safar <marek.safar@gmail.com>2017-10-11 09:57:50 +0300
commit0c61eb1b122b8d98e2e3ad3f443c97bd21e471b2 (patch)
tree4e81a8106b0abec432a013ab03e977226bf06a75
parente004f1ed5e1ee46344c2b5e291350e95d7877e24 (diff)
[reflection] Throw TLE for Type.GetType("", true) (Fixes #59664)
In the C parser check for empty at the outset. In the managed parser, copy an empty string component to the built-up TypeSpec and handle it in the Type.GetType (..., asmResolver, typeResolver) implementation
-rw-r--r--mcs/class/corlib/ReferenceSources/Type.cs21
-rw-r--r--mcs/class/corlib/System/TypeSpec.cs4
-rw-r--r--mono/metadata/reflection.c7
3 files changed, 13 insertions, 19 deletions
diff --git a/mcs/class/corlib/ReferenceSources/Type.cs b/mcs/class/corlib/ReferenceSources/Type.cs
index a77d734c366..664782b1706 100644
--- a/mcs/class/corlib/ReferenceSources/Type.cs
+++ b/mcs/class/corlib/ReferenceSources/Type.cs
@@ -43,22 +43,12 @@ namespace System
public static Type GetType(string typeName)
{
- if (typeName == null)
- throw new ArgumentNullException ("TypeName");
-
- return internal_from_name (typeName, false, false);
+ return GetType (typeName, false, false);
}
public static Type GetType(string typeName, bool throwOnError)
{
- if (typeName == null)
- throw new ArgumentNullException ("TypeName");
-
- Type type = internal_from_name (typeName, throwOnError, false);
- if (throwOnError && type == null)
- throw new TypeLoadException ("Error loading '" + typeName + "'");
-
- return type;
+ return GetType (typeName, throwOnError, false);
}
public static Type GetType(string typeName, bool throwOnError, bool ignoreCase)
@@ -66,6 +56,11 @@ namespace System
if (typeName == null)
throw new ArgumentNullException ("TypeName");
+ if (typeName == String.Empty)
+ if (throwOnError)
+ throw new TypeLoadException ("A null or zero length string does not represent a valid Type.");
+ else
+ return null;
Type t = internal_from_name (typeName, throwOnError, ignoreCase);
if (throwOnError && t == null)
throw new TypeLoadException ("Error loading '" + typeName + "'");
@@ -82,6 +77,8 @@ namespace System
{
if (typeName == null)
throw new ArgumentNullException ("typeName");
+ if (typeName == String.Empty && throwIfNotFound)
+ throw new TypeLoadException ("A null or zero length string does not represent a valid Type");
int idx = typeName.IndexOf (',');
if (idx < 0 || idx == 0 || idx == typeName.Length - 1)
throw new ArgumentException ("Assembly qualifed type name is required", "typeName");
diff --git a/mcs/class/corlib/System/TypeSpec.cs b/mcs/class/corlib/System/TypeSpec.cs
index f233bec088e..4436a77810f 100644
--- a/mcs/class/corlib/System/TypeSpec.cs
+++ b/mcs/class/corlib/System/TypeSpec.cs
@@ -455,7 +455,9 @@ namespace System {
}
if (name_start < pos)
- data.AddName (name.Substring (name_start, pos - name_start));
+ data.AddName (name.Substring (name_start, pos - name_start));
+ else if (name_start == pos)
+ data.AddName (String.Empty);
if (in_modifiers) {
for (; pos < name.Length; ++pos) {
diff --git a/mono/metadata/reflection.c b/mono/metadata/reflection.c
index 3401a59eda0..e69c5d42c28 100644
--- a/mono/metadata/reflection.c
+++ b/mono/metadata/reflection.c
@@ -1546,12 +1546,7 @@ _mono_reflection_parse_type (char *name, char **endptr, gboolean is_recursed,
start = p = w = name;
- //FIXME could we just zero the whole struct? memset (&info, 0, sizeof (MonoTypeNameParse))
- memset (&info->assembly, 0, sizeof (MonoAssemblyName));
- info->name = info->name_space = NULL;
- info->nested = NULL;
- info->modifiers = NULL;
- info->type_arguments = NULL;
+ memset (info, 0, sizeof (MonoTypeNameParse));
/* last_point separates the namespace from the name */
last_point = NULL;