Paul Vriens : crypt32: Fix CertDuplicateCertificateContext for a passed NULL context.

Alexandre Julliard julliard at winehq.org
Thu Jan 29 09:15:44 CST 2009


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

Author: Paul Vriens <Paul.Vriens.Wine at gmail.com>
Date:   Thu Jan 29 13:32:59 2009 +0100

crypt32: Fix CertDuplicateCertificateContext for a passed NULL context.

---

 dlls/crypt32/cert.c       |    4 ++++
 dlls/crypt32/tests/cert.c |   11 +++++++++++
 2 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/dlls/crypt32/cert.c b/dlls/crypt32/cert.c
index c677556..2780cba 100644
--- a/dlls/crypt32/cert.c
+++ b/dlls/crypt32/cert.c
@@ -115,6 +115,10 @@ PCCERT_CONTEXT WINAPI CertDuplicateCertificateContext(
  PCCERT_CONTEXT pCertContext)
 {
     TRACE("(%p)\n", pCertContext);
+
+    if (!pCertContext)
+        return NULL;
+
     Context_AddRef((void *)pCertContext, sizeof(CERT_CONTEXT));
     return pCertContext;
 }
diff --git a/dlls/crypt32/tests/cert.c b/dlls/crypt32/tests/cert.c
index e66b621..844fd28 100644
--- a/dlls/crypt32/tests/cert.c
+++ b/dlls/crypt32/tests/cert.c
@@ -3136,6 +3136,16 @@ static void testGetPublicKeyLength(void)
     ok(ret == 56, "Expected length 56, got %d\n", ret);
 }
 
+static void testCertDuplicateCertificateContext(void)
+{
+    PCCERT_CONTEXT context;
+
+    SetLastError(0xdeadbeef);
+    context = CertDuplicateCertificateContext(NULL);
+    ok(context == NULL, "Expected context to be NULL\n");
+}
+
+
 START_TEST(cert)
 {
     init_function_pointers();
@@ -3163,4 +3173,5 @@ START_TEST(cert)
     testVerifyRevocation();
     testAcquireCertPrivateKey();
     testGetPublicKeyLength();
+    testCertDuplicateCertificateContext();
 }




More information about the wine-cvs mailing list