diff --git a/dlls/crypt32/context.c b/dlls/crypt32/context.c index 0dbf934e0d1..3b344630f78 100644 --- a/dlls/crypt32/context.c +++ b/dlls/crypt32/context.c @@ -137,33 +137,31 @@ struct ContextList *ContextList_Create( return list; } -void *ContextList_Add(struct ContextList *list, void *toLink, void *toReplace, struct WINE_CRYPTCERTSTORE *store, BOOL use_link) +context_t *ContextList_Add(struct ContextList *list, context_t *toLink, context_t *existing, struct WINE_CRYPTCERTSTORE *store, BOOL use_link) { context_t *context; - TRACE("(%p, %p, %p)\n", list, toLink, toReplace); + TRACE("(%p, %p, %p)\n", list, toLink, existing); - context = context_from_ptr(toLink)->vtbl->clone(BASE_CONTEXT_FROM_CONTEXT(toLink), store, use_link); + context = toLink->vtbl->clone(toLink, store, use_link); if (context) { TRACE("adding %p\n", context); EnterCriticalSection(&list->cs); - if (toReplace) + if (existing) { - context_t *existing = context_from_ptr(toReplace); - context->u.entry.prev = existing->u.entry.prev; context->u.entry.next = existing->u.entry.next; context->u.entry.prev->next = &context->u.entry; context->u.entry.next->prev = &context->u.entry; list_init(&existing->u.entry); - Context_Release(context_from_ptr(toReplace)); + Context_Release(existing); } else list_add_head(&list->contexts, &context->u.entry); LeaveCriticalSection(&list->cs); } - return CONTEXT_FROM_BASE_CONTEXT(context); + return context; } void *ContextList_Enum(struct ContextList *list, void *pPrev) diff --git a/dlls/crypt32/crypt32_private.h b/dlls/crypt32/crypt32_private.h index 1c8eae8cbcb..1d7b287a823 100644 --- a/dlls/crypt32/crypt32_private.h +++ b/dlls/crypt32/crypt32_private.h @@ -444,7 +444,7 @@ struct ContextList; struct ContextList *ContextList_Create( const WINE_CONTEXT_INTERFACE *contextInterface, size_t contextSize) DECLSPEC_HIDDEN; -void *ContextList_Add(struct ContextList *list, void *toLink, void *toReplace, +context_t *ContextList_Add(struct ContextList *list, context_t *toLink, context_t *toReplace, struct WINE_CRYPTCERTSTORE *store, BOOL use_link) DECLSPEC_HIDDEN; void *ContextList_Enum(struct ContextList *list, void *pPrev) DECLSPEC_HIDDEN; diff --git a/dlls/crypt32/store.c b/dlls/crypt32/store.c index 08c2a30922d..3381194ebd4 100644 --- a/dlls/crypt32/store.c +++ b/dlls/crypt32/store.c @@ -146,16 +146,18 @@ static BOOL MemStore_addCert(WINECRYPT_CERTSTORE *store, void *cert, void *toReplace, const void **ppStoreContext, BOOL use_link) { WINE_MEMSTORE *ms = (WINE_MEMSTORE *)store; - PCERT_CONTEXT context; + context_t *context; TRACE("(%p, %p, %p, %p)\n", store, cert, toReplace, ppStoreContext); - context = ContextList_Add(ms->certs, cert, toReplace, store, use_link); + context = ContextList_Add(ms->certs, context_from_ptr(cert), toReplace ? context_from_ptr(toReplace) : NULL, store, use_link); if (!context) return FALSE; - if (ppStoreContext) - *ppStoreContext = CertDuplicateCertificateContext(context); + if (ppStoreContext) { + Context_AddRef(context); + *ppStoreContext = context_ptr(context); + } return TRUE; } @@ -188,16 +190,18 @@ static BOOL MemStore_addCRL(WINECRYPT_CERTSTORE *store, void *crl, void *toReplace, const void **ppStoreContext, BOOL use_link) { WINE_MEMSTORE *ms = (WINE_MEMSTORE *)store; - PCRL_CONTEXT context; + context_t *context; TRACE("(%p, %p, %p, %p)\n", store, crl, toReplace, ppStoreContext); - context = ContextList_Add(ms->crls, crl, toReplace, store, use_link); + context = ContextList_Add(ms->crls, context_from_ptr(crl), toReplace ? context_from_ptr(toReplace) : NULL, store, use_link); if (!context) return FALSE; - if (ppStoreContext) - *ppStoreContext = CertDuplicateCRLContext(context); + if (ppStoreContext) { + Context_AddRef(context); + *ppStoreContext = context_ptr(context); + } return TRUE; } @@ -230,16 +234,18 @@ static BOOL MemStore_addCTL(WINECRYPT_CERTSTORE *store, void *ctl, void *toReplace, const void **ppStoreContext, BOOL use_link) { WINE_MEMSTORE *ms = (WINE_MEMSTORE *)store; - PCTL_CONTEXT context; + context_t *context; TRACE("(%p, %p, %p, %p)\n", store, ctl, toReplace, ppStoreContext); - context = ContextList_Add(ms->ctls, ctl, toReplace, store, use_link); + context = ContextList_Add(ms->ctls, context_from_ptr(ctl), toReplace ? context_from_ptr(toReplace) : NULL, store, use_link); if (!context) return FALSE; - if (ppStoreContext) - *ppStoreContext = CertDuplicateCTLContext(context); + if (ppStoreContext) { + Context_AddRef(context); + *ppStoreContext = context_ptr(context); + } return TRUE; }