Commit 06d36b1a authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

ole32: Fix spy callback arguments for IMalloc::GetSize().

parent 1e3bc9f3
......@@ -296,26 +296,33 @@ static void WINAPI IMalloc_fnFree(IMalloc *iface, void *pv)
* win95: size allocated (4 byte boundaries)
* win2k: size originally requested !!! (allocated on 8 byte boundaries)
*/
static SIZE_T WINAPI IMalloc_fnGetSize(IMalloc *iface, void *pv)
static SIZE_T WINAPI IMalloc_fnGetSize(IMalloc *iface, void *mem)
{
SIZE_T cb;
BOOL fSpyed = FALSE;
BOOL spyed_block = FALSE, spy_active = FALSE;
SIZE_T size;
TRACE("(%p)\n",pv);
TRACE("(%p)\n", mem);
if(Malloc32.pSpy) {
EnterCriticalSection(&IMalloc32_SpyCS);
pv = IMallocSpy_PreGetSize(Malloc32.pSpy, pv, fSpyed);
}
if (!mem)
return (SIZE_T)-1;
if (Malloc32.pSpy)
{
EnterCriticalSection(&IMalloc32_SpyCS);
spyed_block = !!mallocspy_is_allocation_spyed(mem);
spy_active = TRUE;
mem = IMallocSpy_PreGetSize(Malloc32.pSpy, mem, spyed_block);
}
cb = HeapSize(GetProcessHeap(),0,pv);
size = HeapSize(GetProcessHeap(), 0, mem);
if(Malloc32.pSpy) {
cb = IMallocSpy_PostGetSize(Malloc32.pSpy, cb, fSpyed);
LeaveCriticalSection(&IMalloc32_SpyCS);
}
if (spy_active)
{
size = IMallocSpy_PostGetSize(Malloc32.pSpy, size, spyed_block);
LeaveCriticalSection(&IMalloc32_SpyCS);
}
return cb;
return size;
}
/******************************************************************************
......
......@@ -3068,6 +3068,7 @@ static void test_CoWaitForMultipleHandles(void)
static void test_CoGetMalloc(void)
{
IMalloc *imalloc;
SIZE_T size;
HRESULT hr;
char *ptr;
int ret;
......@@ -3121,6 +3122,13 @@ static void test_CoGetMalloc(void)
ret = IMalloc_DidAlloc(imalloc, ptr + 4);
ok(ret == 0, "Unexpected return value %d.\n", ret);
/* GetSize() */
size = IMalloc_GetSize(imalloc, NULL);
ok(size == (SIZE_T)-1, "Unexpected return value.\n");
size = IMalloc_GetSize(imalloc, ptr);
ok(size == 16, "Unexpected return value.\n");
IMalloc_Free(imalloc, ptr);
IMalloc_Release(imalloc);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment