- if (ctx->locals [arg]->byref && stack_slot_is_managed_mutability_pointer (value))
- CODE_NOT_VERIFIABLE (ctx, g_strdup_printf ("Cannot use a readonly managed reference when storing on a local variable at 0x%04x", ctx->ip_offset));
-
+ if (ctx->locals [arg]->byref) {
+ if (stack_slot_is_managed_mutability_pointer (value))
+ CODE_NOT_VERIFIABLE (ctx, g_strdup_printf ("Cannot use a readonly managed reference when storing on a local variable at 0x%04x", ctx->ip_offset));
+
+ if (local_is_safe_byref (ctx, arg) && !stack_slot_is_safe_byref (value))
+ CODE_NOT_VERIFIABLE (ctx, g_strdup_printf ("Cannot store an unsafe ret byref to a local that was previously stored a save ret byref value at 0x%04x", ctx->ip_offset));
+
+ if (stack_slot_is_safe_byref (value) && !local_is_unsafe_byref (ctx, arg))
+ ctx->locals_verification_state [arg] |= SAFE_BYREF_LOCAL;
+
+ if (!stack_slot_is_safe_byref (value))
+ ctx->locals_verification_state [arg] |= UNSAFE_BYREF_LOCAL;
+
+ }