Fix finalized invalid handle on TryReadX509Der failure path
authorJeremy Barton <jbarton@microsoft.com>
Fri, 17 Jun 2016 16:50:33 +0000 (09:50 -0700)
committerJeremy Barton <jbarton@microsoft.com>
Fri, 17 Jun 2016 17:35:15 +0000 (10:35 -0700)
Reading a certificate from a byte[] which represented PEM-encoded data
always caused a SafeX509Handle (IsInvalid=true) to be dispatched to the
finalizer queue.

Commit migrated from https://github.com/dotnet/corefx/commit/944ee3ad10885127410822e6b097d6d693e5bc6d

src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Unix/CertificatePal.cs

index 94793cb..7574660 100644 (file)
@@ -128,6 +128,7 @@ namespace Internal.Cryptography.Pal
 
             if (certHandle.IsInvalid)
             {
+                certHandle.Dispose();
                 certPal = null;
                 return false;
             }