crypt32(4/6): Fail earlier if CryptExportPublicKeyInfo fails

Juan Lang juan.lang at gmail.com
Wed May 30 16:23:49 CDT 2012


This was spotted while debugging CertCreateSelfSignSignature, and it
leads to slightly better errors in failure cases.
--Juan
-------------- next part --------------
From 524030d0d9eb9cb5234fb58397f7fbe9fab68280 Mon Sep 17 00:00:00 2001
From: Juan Lang <juan.lang at gmail.com>
Date: Fri, 18 May 2012 15:29:03 -0700
Subject: [PATCH 5/7] Fail earlier if CryptExportPublicKeyInfo fails

---
 dlls/crypt32/cert.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/dlls/crypt32/cert.c b/dlls/crypt32/cert.c
index be7d07c..2d6697c 100644
--- a/dlls/crypt32/cert.c
+++ b/dlls/crypt32/cert.c
@@ -3202,8 +3202,10 @@ PCCERT_CONTEXT WINAPI CertCreateSelfSignCertificate(HCRYPTPROV_OR_NCRYPT_KEY_HAN
         }
     }
 
-    CryptExportPublicKeyInfo(hProv, dwKeySpec, X509_ASN_ENCODING, NULL,
+    ret = CryptExportPublicKeyInfo(hProv, dwKeySpec, X509_ASN_ENCODING, NULL,
      &pubKeySize);
+    if (!ret)
+        goto end;
     pubKey = CryptMemAlloc(pubKeySize);
     if (pubKey)
     {
@@ -3237,6 +3239,7 @@ PCCERT_CONTEXT WINAPI CertCreateSelfSignCertificate(HCRYPTPROV_OR_NCRYPT_KEY_HAN
         }
         CryptMemFree(pubKey);
     }
+end:
     if (releaseContext)
         CryptReleaseContext(hProv, 0);
     return context;
-- 
1.7.7.3


More information about the wine-patches mailing list