Skip to content

Commit

Permalink
[mono] Add a null check to Array.GetRawArrayData (), its needed on pl…
Browse files Browse the repository at this point in the history
…atforms (dotnet#52355)

which use explicit null checks.

Fixes dotnet#50960.
  • Loading branch information
vargaz committed May 6, 2021
1 parent 040e2b3 commit 8f3ac9b
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ namespace System.SpanTests
public static partial class MemoryMarshalTests
{
[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/50960", typeof(PlatformDetection), nameof(PlatformDetection.IsBrowser), nameof(PlatformDetection.IsMonoAOT))]
public static void GetArrayDataReference_NullInput_ThrowsNullRef()
{
Assert.Throws<NullReferenceException>(() => MemoryMarshal.GetArrayDataReference((object[])null));
Expand Down
1 change: 1 addition & 0 deletions src/mono/mono/mini/intrinsics.c
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,7 @@ mini_emit_inst_for_method (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSign
return emit_array_generic_access (cfg, fsig, args, TRUE);
else if (!strcmp (cmethod->name, "GetRawSzArrayData") || !strcmp (cmethod->name, "GetRawArrayData")) {
int dreg = alloc_preg (cfg);
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;
}
Expand Down

0 comments on commit 8f3ac9b

Please sign in to comment.