Skip to content

Commit

Permalink
[release/9.0] Initialize managed and native values in the ICustomMars…
Browse files Browse the repository at this point in the history
…haler marshaler to null when the other is null. (#109096)

* Initialize managed and native values to null when the other is null.

* Update StubHelpers.cs

---------

Co-authored-by: Jeremy Koritzinsky <jekoritz@microsoft.com>
Co-authored-by: Jeremy Koritzinsky <jkoritzinsky@gmail.com>
  • Loading branch information
3 people authored Oct 22, 2024
1 parent 197db4f commit d5baa14
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/coreclr/System.Private.CoreLib/src/System/StubHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -807,17 +807,19 @@ internal static unsafe void ConvertContentsToNative(ICustomMarshaler marshaler,
// COMPAT: We never pass null to MarshalManagedToNative.
if (pManagedHome is null)
{
*pNativeHome = IntPtr.Zero;
return;
}

*pNativeHome = marshaler.MarshalManagedToNative(pManagedHome);
}

internal static void ConvertContentsToManaged(ICustomMarshaler marshaler, ref object pManagedHome, IntPtr* pNativeHome)
internal static void ConvertContentsToManaged(ICustomMarshaler marshaler, ref object? pManagedHome, IntPtr* pNativeHome)
{
// COMPAT: We never pass null to MarshalNativeToManaged.
if (*pNativeHome == IntPtr.Zero)
{
pManagedHome = null;
return;
}

Expand Down

0 comments on commit d5baa14

Please # to comment.