Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 2a1d941

Browse files
committed
Avoid boxing allocation from PtrToStructure in UnmanagedCertificateContext
1 parent 36cf2bb commit 2a1d941

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/Common/src/Interop/Windows/SChannel/UnmanagedCertificateContext.IntPtr.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,11 @@ internal static X509Certificate2Collection GetRemoteCertificatesFromStoreContext
2020
return result;
2121
}
2222

23-
Interop.Crypt32.CERT_CONTEXT context =
24-
Marshal.PtrToStructure<Interop.Crypt32.CERT_CONTEXT>(certContext);
23+
Interop.Crypt32.CERT_CONTEXT context;
24+
unsafe
25+
{
26+
context = *(Interop.Crypt32.CERT_CONTEXT*)certContext;
27+
}
2528

2629
if (context.hCertStore != IntPtr.Zero)
2730
{

0 commit comments

Comments
 (0)