Skip to content

Use Unsafe.NullRef<T>() #79589

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 19, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using Microsoft.Win32.SafeHandles;

Expand Down Expand Up @@ -115,8 +116,12 @@ ref MemoryMarshal.GetReference(input),

internal static void EvpCipherSetInputLength(SafeEvpCipherCtxHandle ctx, int inputLength)
{
ref byte nullRef = ref MemoryMarshal.GetReference(Span<byte>.Empty);
if (!EvpCipherUpdate(ctx, ref nullRef, out _, ref nullRef, inputLength))
if (!EvpCipherUpdate(
ctx,
ref Unsafe.NullRef<byte>(),
out _,
ref Unsafe.NullRef<byte>(),
inputLength))
{
throw CreateOpenSslCryptographicException();
}
Expand Down Expand Up @@ -229,8 +234,7 @@ internal static void EvpCipherSetCcmTag(SafeEvpCipherCtxHandle ctx, ReadOnlySpan

internal static void EvpCipherSetCcmTagLength(SafeEvpCipherCtxHandle ctx, int tagLength)
{
ref byte nullRef = ref MemoryMarshal.GetReference(Span<byte>.Empty);
if (!EvpCipherSetCcmTag(ctx, ref nullRef, tagLength))
if (!EvpCipherSetCcmTag(ctx, ref Unsafe.NullRef<byte>(), tagLength))
{
throw CreateOpenSslCryptographicException();
}
Expand Down