Module: wine Branch: master Commit: dd26bee14c92c60f92177867bf77138907d7fac1 URL: http://source.winehq.org/git/wine.git/?a=commit;h=dd26bee14c92c60f92177867bf...
Author: Juan Lang juan.lang@gmail.com Date: Tue Oct 20 09:54:56 2009 -0700
crypt32: Fix duplicating a NULL CTL context.
---
dlls/crypt32/ctl.c | 3 ++- dlls/crypt32/tests/ctl.c | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletions(-)
diff --git a/dlls/crypt32/ctl.c b/dlls/crypt32/ctl.c index 5a6d19b..1bd60e7 100644 --- a/dlls/crypt32/ctl.c +++ b/dlls/crypt32/ctl.c @@ -455,7 +455,8 @@ end: PCCTL_CONTEXT WINAPI CertDuplicateCTLContext(PCCTL_CONTEXT pCtlContext) { TRACE("(%p)\n", pCtlContext); - Context_AddRef((void *)pCtlContext, sizeof(CTL_CONTEXT)); + if (pCtlContext) + Context_AddRef((void *)pCtlContext, sizeof(CTL_CONTEXT)); return pCtlContext; }
diff --git a/dlls/crypt32/tests/ctl.c b/dlls/crypt32/tests/ctl.c index f09420c..8ee2652 100644 --- a/dlls/crypt32/tests/ctl.c +++ b/dlls/crypt32/tests/ctl.c @@ -187,6 +187,21 @@ static void testCreateCTL(void) CertFreeCTLContext(ctl); }
+static void testDupCTL(void) +{ + PCCTL_CONTEXT context, dupContext; + + context = CertDuplicateCTLContext(NULL); + ok(context == NULL, "expected NULL\n"); + context = CertCreateCTLContext(X509_ASN_ENCODING, + signedCTLWithCTLInnerContent, sizeof(signedCTLWithCTLInnerContent)); + dupContext = CertDuplicateCTLContext(context); + ok(dupContext != NULL, "expected a context\n"); + ok(dupContext == context, "expected identical context addresses\n"); + CertFreeCTLContext(dupContext); + CertFreeCTLContext(context); +} + static void checkHash(const BYTE *data, DWORD dataLen, ALG_ID algID, PCCTL_CONTEXT context, DWORD propID) { @@ -444,6 +459,7 @@ static void testAddCTLToStore(void) START_TEST(ctl) { testCreateCTL(); + testDupCTL(); testCTLProperties(); testAddCTLToStore(); }