ole32: Improve locking safety in IMalloc::Free().
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
ed53127580
commit
da5903e7d1
|
@ -254,28 +254,32 @@ static void * WINAPI IMalloc_fnRealloc(IMalloc *iface, void *pv, SIZE_T cb)
|
|||
/******************************************************************************
|
||||
* IMalloc32_Free [VTABLE]
|
||||
*/
|
||||
static void WINAPI IMalloc_fnFree(IMalloc *iface, void *pv)
|
||||
static void WINAPI IMalloc_fnFree(IMalloc *iface, void *mem)
|
||||
{
|
||||
BOOL fSpyed = FALSE;
|
||||
BOOL spyed_block = FALSE, spy_active = FALSE;
|
||||
|
||||
TRACE("(%p)\n",pv);
|
||||
TRACE("(%p)\n", mem);
|
||||
|
||||
if(!pv)
|
||||
if (!mem)
|
||||
return;
|
||||
|
||||
if(Malloc32.pSpy) {
|
||||
if (Malloc32.pSpy)
|
||||
{
|
||||
EnterCriticalSection(&IMalloc32_SpyCS);
|
||||
fSpyed = mallocspy_remove_spyed_memory(pv);
|
||||
pv = IMallocSpy_PreFree(Malloc32.pSpy, pv, fSpyed);
|
||||
spyed_block = mallocspy_remove_spyed_memory(mem);
|
||||
spy_active = TRUE;
|
||||
mem = IMallocSpy_PreFree(Malloc32.pSpy, mem, spyed_block);
|
||||
}
|
||||
|
||||
HeapFree(GetProcessHeap(),0,pv);
|
||||
HeapFree(GetProcessHeap(), 0, mem);
|
||||
|
||||
if(Malloc32.pSpy) {
|
||||
IMallocSpy_PostFree(Malloc32.pSpy, fSpyed);
|
||||
if (spy_active)
|
||||
{
|
||||
IMallocSpy_PostFree(Malloc32.pSpy, spyed_block);
|
||||
|
||||
/* check if can release the spy */
|
||||
if(Malloc32.SpyReleasePending && !Malloc32.SpyedAllocationsLeft) {
|
||||
if (Malloc32.SpyReleasePending && !Malloc32.SpyedAllocationsLeft)
|
||||
{
|
||||
IMallocSpy_Release(Malloc32.pSpy);
|
||||
Malloc32.SpyReleasePending = FALSE;
|
||||
Malloc32.pSpy = NULL;
|
||||
|
|
Loading…
Reference in New Issue