From 6d4f4019bb3b13bc6e699e784f2d4b76e8ab5da3 Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Tue, 26 Jul 2022 19:52:05 -0400 Subject: [PATCH] [mini] Emit a null check using MONO_EMIT_NEW_CHECK_THIS for GetArrayDataReference using MONO_EMIT_NULL_CHECK does not emit a null check in the backend if the pointer is otherwise unused Fixes https://github.com/dotnet/runtime/issues/72745 --- src/mono/mono/mini/intrinsics.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mono/mono/mini/intrinsics.c b/src/mono/mono/mini/intrinsics.c index 1e05a4abaa2ea..ce959ccbf0a74 100644 --- a/src/mono/mono/mini/intrinsics.c +++ b/src/mono/mono/mini/intrinsics.c @@ -1008,7 +1008,8 @@ mini_emit_inst_for_method (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSign if (!strcmp (cmethod->name, "GetArrayDataReference")) { // Logic below works for both SZARRAY and MDARRAY int dreg = alloc_preg (cfg); - MONO_EMIT_NULL_CHECK (cfg, args [0]->dreg, FALSE); + MONO_EMIT_NEW_CHECK_THIS(cfg, args[0]->dreg); + //MONO_EMIT_NULL_CHECK (cfg, args [0]->dreg, FALSE); EMIT_NEW_BIALU_IMM (cfg, ins, OP_PADD_IMM, dreg, args [0]->dreg, MONO_STRUCT_OFFSET (MonoArray, vector)); return ins; }