Skip to content

Commit

Permalink
[corlib] Fix for mono#8543 Crash when using Delegate.CreateDelegate w…
Browse files Browse the repository at this point in the history
…ith DynamicMethod
  • Loading branch information
Vivek Raj committed Jul 8, 2018
1 parent 998365a commit 7288778
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions mcs/class/corlib/System/Delegate.cs
Expand Up @@ -185,6 +185,16 @@ static Delegate CreateDelegate (Type type, object firstArgument, MethodInfo meth
if (!type.IsSubclassOf (typeof (MulticastDelegate)))
throw new ArgumentException ("type is not a subclass of Multicastdelegate");

RuntimeType rtType = type as RuntimeType;

if (rtType == null)
throw new ArgumentException ("Type must be a RuntimeType");

RuntimeMethodInfo rmi = method as RuntimeMethodInfo;

if (rmi == null)
throw new ArgumentException ("MethodInfo must be a RuntimeMethodInfo");

MethodInfo invoke = type.GetMethod ("Invoke");

if (!return_type_match (invoke.ReturnType, method.ReturnType)) {
Expand Down

0 comments on commit 7288778

Please sign in to comment.