[PATCH] crypt32/tests: Print an error if CertOpenStore fails.

Alex Henrie alexhenrie24 at gmail.com
Fri Mar 10 00:03:50 CST 2017


Also fixes the unintentional memory leak in testFindCRL if
CertFindCRLInStore or CertFindCertificateInCRL are unavailable.

Supersedes https://source.winehq.org/patches/data/130806

Signed-off-by: Alex Henrie <alexhenrie24 at gmail.com>
---
 dlls/crypt32/tests/crl.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/dlls/crypt32/tests/crl.c b/dlls/crypt32/tests/crl.c
index 9515c38115..c350b20f00 100644
--- a/dlls/crypt32/tests/crl.c
+++ b/dlls/crypt32/tests/crl.c
@@ -148,6 +148,7 @@ static void testAddCRL(void)
     BOOL ret;
     DWORD GLE;
 
+    ok(store != NULL, "CertOpenStore failed: %08x\n", GetLastError());
     if (!store) return;
 
     /* Bad CRL encoding type */
@@ -425,21 +426,24 @@ static const BYTE rootSignedCRL[] = {
 
 static void testFindCRL(void)
 {
-    HCERTSTORE store = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0,
-     CERT_STORE_CREATE_NEW_FLAG, NULL);
+    HCERTSTORE store;
     PCCRL_CONTEXT context;
     PCCERT_CONTEXT cert, endCert, rootCert;
     CRL_FIND_ISSUED_FOR_PARA issuedForPara = { NULL, NULL };
     DWORD count, revoked_count;
     BOOL ret;
 
-    if (!store) return;
     if (!pCertFindCRLInStore || !pCertFindCertificateInCRL)
     {
         win_skip("CertFindCRLInStore or CertFindCertificateInCRL not available\n");
         return;
     }
 
+    store = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0,
+                          CERT_STORE_CREATE_NEW_FLAG, NULL);
+    ok(store != NULL, "CertOpenStore failed: %08x\n", GetLastError());
+    if (!store) return;
+
     ret = CertAddEncodedCRLToStore(store, X509_ASN_ENCODING, signedCRL,
      sizeof(signedCRL), CERT_STORE_ADD_ALWAYS, NULL);
     ok(ret, "CertAddEncodedCRLToStore failed: %08x\n", GetLastError());
@@ -783,6 +787,7 @@ static void testGetCRLFromStore(void)
     DWORD flags;
     BOOL ret;
 
+    ok(store != NULL, "CertOpenStore failed: %08x\n", GetLastError());
     if (!store) return;
 
     /* Crash
-- 
2.12.0




More information about the wine-patches mailing list