X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Fmetadata%2Fverify.c;h=18584ba8288f241c6bb2d214934d66c813b0218f;hb=e53c11cdaed789cc71a55a176800eb45c2c051ce;hp=2d1833027ff2c48018a0e3990d7007ff28019869;hpb=9dfe49970951c68f14f14bed004d859f2857542e;p=mono.git diff --git a/mono/metadata/verify.c b/mono/metadata/verify.c index 2d1833027ff..18584ba8288 100644 --- a/mono/metadata/verify.c +++ b/mono/metadata/verify.c @@ -2833,6 +2833,22 @@ do_newarr (VerifyContext *ctx, int token) set_stack_value (stack_push (ctx), mono_class_get_type (mono_array_class_get (mono_class_from_mono_type (type), 1)), FALSE); } +static void +do_ldlen (VerifyContext *ctx) +{ + ILStackDesc *value; + + if (!check_underflow (ctx, 1)) + return; + + value = stack_pop (ctx); + + if (value->stype != TYPE_COMPLEX || value->type->type != MONO_TYPE_SZARRAY) + CODE_NOT_VERIFIABLE (ctx, g_strdup_printf ("Invalid array type for ldlen at 0x%04x", ctx->ip_offset)); + + stack_push_val (ctx, TYPE_NATIVE_INT, &mono_defaults.int_class->byval_arg); +} + /*Merge the stacks and perform compat checks*/ static void merge_stacks (VerifyContext *ctx, ILCodeDesc *from, ILCodeDesc *to, int start) @@ -3447,14 +3463,10 @@ mono_method_verify (MonoMethod *method, int level) break; case CEE_LDLEN: - if (!check_underflow (&ctx, 1)) - break; - if (stack_top (&ctx)->stype != TYPE_COMPLEX) - ADD_VERIFY_ERROR (&ctx, g_strdup_printf ("Invalid argument to ldlen at 0x%04x", ip_offset)); - stack_top (&ctx)->type = &mono_defaults.int32_class->byval_arg; /* FIXME: use a native int type */ - stack_top (&ctx)->stype = TYPE_PTR; + do_ldlen (&ctx); ++ip; break; + case CEE_LDELEMA: if (check_underflow (&ctx, 2)) break;