Skip to content

Commit

Permalink
compobj: Reference the IMalloc pointer in CoInitialize().
Browse files Browse the repository at this point in the history
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=42554
Signed-off-by: Zebediah Figura <[email protected]>
Signed-off-by: Alexandre Julliard <[email protected]>
  • Loading branch information
zfigura authored and julliard committed Jan 21, 2020
1 parent ba3ca99 commit 588af8c
Showing 1 changed file with 30 additions and 4 deletions.
34 changes: 30 additions & 4 deletions dlls/compobj.dll16/compobj.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,28 @@ typedef struct
SEGPTR lpVtbl;
} IMalloc16;

static ULONG call_IMalloc_AddRef(SEGPTR iface)
{
IMalloc16 *malloc = MapSL(iface);
IMalloc16Vtbl *vtbl = MapSL(malloc->lpVtbl);
DWORD args[1], ret;

args[0] = iface;
WOWCallback16Ex(vtbl->AddRef, WCB16_CDECL, sizeof(args), args, &ret);
return ret;
}

static ULONG call_IMalloc_Release(SEGPTR iface)
{
IMalloc16 *malloc = MapSL(iface);
IMalloc16Vtbl *vtbl = MapSL(malloc->lpVtbl);
DWORD args[1], ret;

args[0] = iface;
WOWCallback16Ex(vtbl->Release, WCB16_CDECL, sizeof(args), args, &ret);
return ret;
}

static SEGPTR call_IMalloc_Alloc(SEGPTR iface, DWORD size)
{
IMalloc16 *malloc = MapSL(iface);
Expand Down Expand Up @@ -288,8 +310,9 @@ SEGPTR WINAPI CoMemAlloc(DWORD size, MEMCTX context, DWORD unknown)
HRESULT WINAPI CoInitialize16(SEGPTR malloc)
{
if (!malloc)
CoCreateStandardMalloc16(MEMCTX_TASK, &malloc);
compobj_malloc = malloc;
CoCreateStandardMalloc16(MEMCTX_TASK, &compobj_malloc);
else
call_IMalloc_AddRef(compobj_malloc = malloc);
return S_OK;
}

Expand All @@ -301,8 +324,11 @@ HRESULT WINAPI CoInitialize16(SEGPTR malloc)
*/
void WINAPI CoUninitialize16(void)
{
TRACE("()\n");
CoFreeAllLibraries();
TRACE("\n");

CoFreeAllLibraries();
call_IMalloc_Release(compobj_malloc);
compobj_malloc = 0;
}

/***********************************************************************
Expand Down

0 comments on commit 588af8c

Please sign in to comment.