[PATCH] Fix CertDuplicateCertificateContext for a passed NULL context
Paul Vriens
Paul.Vriens.Wine at gmail.com
Thu Jan 29 06:32:59 CST 2009
---
dlls/crypt32/cert.c | 4 ++++
dlls/crypt32/tests/cert.c | 12 ++++++++++++
2 files changed, 16 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..92361ec 100644
--- a/dlls/crypt32/tests/cert.c
+++ b/dlls/crypt32/tests/cert.c
@@ -3136,6 +3136,17 @@ static void testGetPublicKeyLength(void)
ok(ret == 56, "Expected length 56, got %d\n", ret);
}
+static void testCertDuplicateCertificateContext(void)
+{
+ PCCERT_CONTEXT context;
+
+ context = 0xdeadbeef;
+ SetLastError(0xdeadbeef);
+ context = CertDuplicateCertificateContext(NULL);
+ ok(context == NULL, "Expected context to be NULL\n");
+}
+
+
START_TEST(cert)
{
init_function_pointers();
@@ -3163,4 +3174,5 @@ START_TEST(cert)
testVerifyRevocation();
testAcquireCertPrivateKey();
testGetPublicKeyLength();
+ testCertDuplicateCertificateContext();
}
--
1.6.0.6
--------------080103060501070408060006--
More information about the wine-patches
mailing list