Marcus Meissner : crypt32: Avoid NULL ptr dereferences before checks ( Coverity).

Alexandre Julliard julliard at winehq.org
Mon Oct 28 15:13:06 CDT 2013


Module: wine
Branch: master
Commit: cf1bbb3bb88ea8f6fdcffe3c203b379118aad6ec
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=cf1bbb3bb88ea8f6fdcffe3c203b379118aad6ec

Author: Marcus Meissner <marcus at jet.franken.de>
Date:   Sat Oct 26 10:33:23 2013 +0200

crypt32: Avoid NULL ptr dereferences before checks (Coverity).

---

 dlls/crypt32/ctl.c   |    4 +++-
 dlls/crypt32/store.c |    8 ++++++--
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/dlls/crypt32/ctl.c b/dlls/crypt32/ctl.c
index fa98556..c18e608 100644
--- a/dlls/crypt32/ctl.c
+++ b/dlls/crypt32/ctl.c
@@ -341,7 +341,7 @@ PCCTL_CONTEXT WINAPI CertFindCTLInStore(HCERTSTORE hCertStore,
 
 BOOL WINAPI CertDeleteCTLFromStore(PCCTL_CONTEXT pCtlContext)
 {
-    WINECRYPT_CERTSTORE *hcs = pCtlContext->hCertStore;
+    WINECRYPT_CERTSTORE *hcs;
     ctl_t *ctl = ctl_from_ptr(pCtlContext);
     BOOL ret;
 
@@ -350,6 +350,8 @@ BOOL WINAPI CertDeleteCTLFromStore(PCCTL_CONTEXT pCtlContext)
     if (!pCtlContext)
         return TRUE;
 
+    hcs = pCtlContext->hCertStore;
+
     if (hcs->dwMagic != WINE_CRYPTCERTSTORE_MAGIC)
             return FALSE;
 
diff --git a/dlls/crypt32/store.c b/dlls/crypt32/store.c
index 6c34e55..d5d7443 100644
--- a/dlls/crypt32/store.c
+++ b/dlls/crypt32/store.c
@@ -949,13 +949,15 @@ PCCERT_CONTEXT WINAPI CertEnumCertificatesInStore(HCERTSTORE hCertStore, PCCERT_
 
 BOOL WINAPI CertDeleteCertificateFromStore(PCCERT_CONTEXT pCertContext)
 {
-    WINECRYPT_CERTSTORE *hcs = pCertContext->hCertStore;
+    WINECRYPT_CERTSTORE *hcs;
 
     TRACE("(%p)\n", pCertContext);
 
     if (!pCertContext)
         return TRUE;
 
+    hcs = pCertContext->hCertStore;
+
     if (hcs->dwMagic != WINE_CRYPTCERTSTORE_MAGIC)
         return FALSE;
 
@@ -1084,7 +1086,7 @@ BOOL WINAPI CertAddCRLContextToStore(HCERTSTORE hCertStore,
 
 BOOL WINAPI CertDeleteCRLFromStore(PCCRL_CONTEXT pCrlContext)
 {
-    WINECRYPT_CERTSTORE *hcs = pCrlContext->hCertStore;
+    WINECRYPT_CERTSTORE *hcs;
     BOOL ret;
 
     TRACE("(%p)\n", pCrlContext);
@@ -1092,6 +1094,8 @@ BOOL WINAPI CertDeleteCRLFromStore(PCCRL_CONTEXT pCrlContext)
     if (!pCrlContext)
         return TRUE;
 
+    hcs = pCrlContext->hCertStore;
+
     if (hcs->dwMagic != WINE_CRYPTCERTSTORE_MAGIC)
         return FALSE;
 




More information about the wine-cvs mailing list