mirror of
https://github.com/reactos/wine.git
synced 2025-01-31 17:23:53 +00:00
crypt32: Add return value to Context_Release to allow detecting reference counting errors.
This commit is contained in:
parent
f4b359942b
commit
40855cae97
@ -180,12 +180,14 @@ static void CertDataContext_Free(void *context)
|
|||||||
|
|
||||||
BOOL WINAPI CertFreeCertificateContext(PCCERT_CONTEXT pCertContext)
|
BOOL WINAPI CertFreeCertificateContext(PCCERT_CONTEXT pCertContext)
|
||||||
{
|
{
|
||||||
|
BOOL ret = TRUE;
|
||||||
|
|
||||||
TRACE("(%p)\n", pCertContext);
|
TRACE("(%p)\n", pCertContext);
|
||||||
|
|
||||||
if (pCertContext)
|
if (pCertContext)
|
||||||
Context_Release((void *)pCertContext, sizeof(CERT_CONTEXT),
|
ret = Context_Release((void *)pCertContext, sizeof(CERT_CONTEXT),
|
||||||
CertDataContext_Free);
|
CertDataContext_Free);
|
||||||
return TRUE;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD WINAPI CertEnumCertificateContextProperties(PCCERT_CONTEXT pCertContext,
|
DWORD WINAPI CertEnumCertificateContextProperties(PCCERT_CONTEXT pCertContext,
|
||||||
|
@ -135,11 +135,14 @@ PCONTEXT_PROPERTY_LIST Context_GetProperties(const void *context, size_t context
|
|||||||
((PDATA_CONTEXT)ptr)->properties : NULL;
|
((PDATA_CONTEXT)ptr)->properties : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Context_Release(void *context, size_t contextSize,
|
BOOL Context_Release(void *context, size_t contextSize,
|
||||||
ContextFreeFunc dataContextFree)
|
ContextFreeFunc dataContextFree)
|
||||||
{
|
{
|
||||||
PBASE_CONTEXT base = BASE_CONTEXT_FROM_CONTEXT(context, contextSize);
|
PBASE_CONTEXT base = BASE_CONTEXT_FROM_CONTEXT(context, contextSize);
|
||||||
|
BOOL ret = TRUE;
|
||||||
|
|
||||||
|
if (base->ref <= 0)
|
||||||
|
return FALSE;
|
||||||
if (InterlockedDecrement(&base->ref) == 0)
|
if (InterlockedDecrement(&base->ref) == 0)
|
||||||
{
|
{
|
||||||
TRACE("freeing %p\n", context);
|
TRACE("freeing %p\n", context);
|
||||||
@ -153,7 +156,7 @@ void Context_Release(void *context, size_t contextSize,
|
|||||||
/* The linked context is of the same type as this, so release
|
/* The linked context is of the same type as this, so release
|
||||||
* it as well, using the same offset and data free function.
|
* it as well, using the same offset and data free function.
|
||||||
*/
|
*/
|
||||||
Context_Release(CONTEXT_FROM_BASE_CONTEXT(
|
ret = Context_Release(CONTEXT_FROM_BASE_CONTEXT(
|
||||||
((PLINK_CONTEXT)base)->linked, contextSize), contextSize,
|
((PLINK_CONTEXT)base)->linked, contextSize), contextSize,
|
||||||
dataContextFree);
|
dataContextFree);
|
||||||
break;
|
break;
|
||||||
@ -164,6 +167,7 @@ void Context_Release(void *context, size_t contextSize,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
TRACE("%p's ref count is %d\n", context, base->ref);
|
TRACE("%p's ref count is %d\n", context, base->ref);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Context_CopyProperties(const void *to, const void *from,
|
void Context_CopyProperties(const void *to, const void *from,
|
||||||
|
@ -243,12 +243,14 @@ static void CrlDataContext_Free(void *context)
|
|||||||
|
|
||||||
BOOL WINAPI CertFreeCRLContext( PCCRL_CONTEXT pCrlContext)
|
BOOL WINAPI CertFreeCRLContext( PCCRL_CONTEXT pCrlContext)
|
||||||
{
|
{
|
||||||
|
BOOL ret = TRUE;
|
||||||
|
|
||||||
TRACE("(%p)\n", pCrlContext);
|
TRACE("(%p)\n", pCrlContext);
|
||||||
|
|
||||||
if (pCrlContext)
|
if (pCrlContext)
|
||||||
Context_Release((void *)pCrlContext, sizeof(CRL_CONTEXT),
|
ret = Context_Release((void *)pCrlContext, sizeof(CRL_CONTEXT),
|
||||||
CrlDataContext_Free);
|
CrlDataContext_Free);
|
||||||
return TRUE;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD WINAPI CertEnumCRLContextProperties(PCCRL_CONTEXT pCRLContext,
|
DWORD WINAPI CertEnumCRLContextProperties(PCCRL_CONTEXT pCRLContext,
|
||||||
|
@ -346,8 +346,9 @@ typedef void (*ContextFreeFunc)(void *context);
|
|||||||
/* Decrements context's ref count. If context is a link context, releases its
|
/* Decrements context's ref count. If context is a link context, releases its
|
||||||
* linked context as well.
|
* linked context as well.
|
||||||
* If a data context has its ref count reach 0, calls dataContextFree on it.
|
* If a data context has its ref count reach 0, calls dataContextFree on it.
|
||||||
|
* Returns FALSE if the reference count is <= 0 when called.
|
||||||
*/
|
*/
|
||||||
void Context_Release(void *context, size_t contextSize,
|
BOOL Context_Release(void *context, size_t contextSize,
|
||||||
ContextFreeFunc dataContextFree);
|
ContextFreeFunc dataContextFree);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -472,12 +472,14 @@ static void CTLDataContext_Free(void *context)
|
|||||||
|
|
||||||
BOOL WINAPI CertFreeCTLContext(PCCTL_CONTEXT pCTLContext)
|
BOOL WINAPI CertFreeCTLContext(PCCTL_CONTEXT pCTLContext)
|
||||||
{
|
{
|
||||||
|
BOOL ret = TRUE;
|
||||||
|
|
||||||
TRACE("(%p)\n", pCTLContext);
|
TRACE("(%p)\n", pCTLContext);
|
||||||
|
|
||||||
if (pCTLContext)
|
if (pCTLContext)
|
||||||
Context_Release((void *)pCTLContext, sizeof(CTL_CONTEXT),
|
ret = Context_Release((void *)pCTLContext, sizeof(CTL_CONTEXT),
|
||||||
CTLDataContext_Free);
|
CTLDataContext_Free);
|
||||||
return TRUE;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD WINAPI CertEnumCTLContextProperties(PCCTL_CONTEXT pCTLContext,
|
DWORD WINAPI CertEnumCTLContextProperties(PCCTL_CONTEXT pCTLContext,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user