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) ...@@ -296,26 +296,33 @@ static void WINAPI IMalloc_fnFree(IMalloc *iface, void *pv)
* win95: size allocated (4 byte boundaries) * win95: size allocated (4 byte boundaries)
* win2k: size originally requested !!! (allocated on 8 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 spyed_block = FALSE, spy_active = FALSE;
BOOL fSpyed = FALSE; SIZE_T size;
TRACE("(%p)\n",pv); TRACE("(%p)\n", mem);
if(Malloc32.pSpy) { if (!mem)
EnterCriticalSection(&IMalloc32_SpyCS); return (SIZE_T)-1;
pv = IMallocSpy_PreGetSize(Malloc32.pSpy, pv, fSpyed);
} 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) { if (spy_active)
cb = IMallocSpy_PostGetSize(Malloc32.pSpy, cb, fSpyed); {
LeaveCriticalSection(&IMalloc32_SpyCS); size = IMallocSpy_PostGetSize(Malloc32.pSpy, size, spyed_block);
} LeaveCriticalSection(&IMalloc32_SpyCS);
}
return cb; return size;
} }
/****************************************************************************** /******************************************************************************
......
...@@ -3068,6 +3068,7 @@ static void test_CoWaitForMultipleHandles(void) ...@@ -3068,6 +3068,7 @@ static void test_CoWaitForMultipleHandles(void)
static void test_CoGetMalloc(void) static void test_CoGetMalloc(void)
{ {
IMalloc *imalloc; IMalloc *imalloc;
SIZE_T size;
HRESULT hr; HRESULT hr;
char *ptr; char *ptr;
int ret; int ret;
...@@ -3121,6 +3122,13 @@ static void test_CoGetMalloc(void) ...@@ -3121,6 +3122,13 @@ static void test_CoGetMalloc(void)
ret = IMalloc_DidAlloc(imalloc, ptr + 4); ret = IMalloc_DidAlloc(imalloc, ptr + 4);
ok(ret == 0, "Unexpected return value %d.\n", ret); 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_Free(imalloc, ptr);
IMalloc_Release(imalloc); 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