2008-02-28 Rodrigo Kumpera <rkumpera@novell.com>
authorRodrigo Kumpera <kumpera@gmail.com>
Thu, 28 Feb 2008 17:10:30 +0000 (17:10 -0000)
committerRodrigo Kumpera <kumpera@gmail.com>
Thu, 28 Feb 2008 17:10:30 +0000 (17:10 -0000)
* verify.c (do_refanytype): Verify the refanytype opcode.

* verify.c (mono_method_verify): Use do_refanytype.

svn path=/trunk/mono/; revision=96902

mono/metadata/ChangeLog
mono/metadata/verify.c

index 3b3ac58d0f77c728b3b20ff944477d6d60eda0c0..10d83fa961e219c5331947cd6e9e0d0bea15b85d 100644 (file)
@@ -1,3 +1,9 @@
+2008-02-28 Rodrigo Kumpera  <rkumpera@novell.com>
+
+       * verify.c (do_refanytype): Verify the refanytype opcode.
+
+       * verify.c (mono_method_verify): Use do_refanytype.
+
 2008-02-28 Rodrigo Kumpera  <rkumpera@novell.com>
 
        * verify.c (do_mkrefany): Verify the mkrefany opcode.
index 2cf47a604e8c4742996693e6750b457a55591874..ccaecf9cf56dde030969257a232b7721a59554ed 100644 (file)
@@ -3809,6 +3809,23 @@ do_refanyval (VerifyContext *ctx, int token)
        set_stack_value (ctx, stack_push (ctx), type, TRUE);
 }
 
+static void
+do_refanytype (VerifyContext *ctx)
+{
+       ILStackDesc *top;
+
+       if (!check_underflow (ctx, 1))
+               return;
+
+       top = stack_pop (ctx);
+
+       if (top->stype != TYPE_PTR || top->type->type != MONO_TYPE_TYPEDBYREF)
+               ADD_VERIFY_ERROR (ctx, g_strdup_printf ("Expected a typedref as argument for refanytype, but found %s at 0x%04x", stack_slot_get_name (top), ctx->ip_offset));
+
+       set_stack_value (ctx, stack_push (ctx), &mono_defaults.typehandle_class->byval_arg, FALSE);
+
+}
+
 static void
 do_mkrefany (VerifyContext *ctx, int token)
 {
@@ -4974,10 +4991,10 @@ mono_method_verify (MonoMethod *method, int level)
                                break;
 
                        case CEE_REFANYTYPE:
-                               if (!check_underflow (&ctx, 1))
-                                       break;
+                               do_refanytype (&ctx);
                                ++ip;
                                break;
+
                        case CEE_UNUSED53:
                        case CEE_UNUSED54:
                        case CEE_UNUSED55: