Skip to content

Commit

Permalink
Dispose transient CFData in Interop.AppleCrypto.X509GetRawData
Browse files Browse the repository at this point in the history
  • Loading branch information
odhanson committed Jun 21, 2021
1 parent 0cdd423 commit 44bb2ad
Showing 1 changed file with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,21 @@ internal static byte[] X509GetRawData(SafeSecCertificateHandle cert)
out data,
out osStatus);

if (ret == 1)
using (data)
{
return CoreFoundation.CFGetData(data);
if (ret == 1)
{
return CoreFoundation.CFGetData(data);
}

if (ret == 0)
{
throw CreateExceptionForOSStatus(osStatus);
}

Debug.Fail($"Unexpected return value {ret}");
throw new CryptographicException();
}

if (ret == 0)
{
throw CreateExceptionForOSStatus(osStatus);
}

Debug.Fail($"Unexpected return value {ret}");
throw new CryptographicException();
}

internal static SafeSecKeyRefHandle X509GetPrivateKeyFromIdentity(SafeSecIdentityHandle identity)
Expand Down

0 comments on commit 44bb2ad

Please sign in to comment.