ole32: Improve CoRegisterMallocSpy/CoRevokeMallocSpy state and parameter validation.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Huw Davies <huw@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
110665a3d8
commit
cef4c7dc69
@ -464,8 +464,9 @@ HRESULT WINAPI CoRegisterMallocSpy(LPMALLOCSPY pMallocSpy)
|
|||||||
IMallocSpy* pSpy;
|
IMallocSpy* pSpy;
|
||||||
HRESULT hres = E_INVALIDARG;
|
HRESULT hres = E_INVALIDARG;
|
||||||
|
|
||||||
TRACE("\n");
|
TRACE("%p\n", pMallocSpy);
|
||||||
|
|
||||||
|
if(!pMallocSpy) return E_INVALIDARG;
|
||||||
if(Malloc32.pSpy) return CO_E_OBJISREG;
|
if(Malloc32.pSpy) return CO_E_OBJISREG;
|
||||||
|
|
||||||
EnterCriticalSection(&IMalloc32_SpyCS);
|
EnterCriticalSection(&IMalloc32_SpyCS);
|
||||||
@ -504,7 +505,9 @@ HRESULT WINAPI CoRevokeMallocSpy(void)
|
|||||||
|
|
||||||
EnterCriticalSection(&IMalloc32_SpyCS);
|
EnterCriticalSection(&IMalloc32_SpyCS);
|
||||||
|
|
||||||
if (Malloc32.SpyedAllocationsLeft) {
|
if (!Malloc32.pSpy)
|
||||||
|
hres = CO_E_OBJNOTREG;
|
||||||
|
else if (Malloc32.SpyedAllocationsLeft) {
|
||||||
TRACE("SpyReleasePending with %u allocations left\n", Malloc32.SpyedAllocationsLeft);
|
TRACE("SpyReleasePending with %u allocations left\n", Malloc32.SpyedAllocationsLeft);
|
||||||
Malloc32.SpyReleasePending = TRUE;
|
Malloc32.SpyReleasePending = TRUE;
|
||||||
hres = E_ACCESSDENIED;
|
hres = E_ACCESSDENIED;
|
||||||
|
@ -3051,9 +3051,21 @@ static void test_IMallocSpy(void)
|
|||||||
IMalloc *imalloc;
|
IMalloc *imalloc;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
|
hr = CoRegisterMallocSpy(NULL);
|
||||||
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
||||||
|
|
||||||
|
hr = CoRevokeMallocSpy();
|
||||||
|
ok(hr == CO_E_OBJNOTREG, "got 0x%08x\n", hr);
|
||||||
|
|
||||||
hr = CoRegisterMallocSpy(&testspy);
|
hr = CoRegisterMallocSpy(&testspy);
|
||||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||||
|
|
||||||
|
hr = CoRegisterMallocSpy(NULL);
|
||||||
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
||||||
|
|
||||||
|
hr = CoRegisterMallocSpy(&testspy);
|
||||||
|
ok(hr == CO_E_OBJISREG, "got 0x%08x\n", hr);
|
||||||
|
|
||||||
imalloc = NULL;
|
imalloc = NULL;
|
||||||
hr = CoGetMalloc(MEMCTX_TASK, &imalloc);
|
hr = CoGetMalloc(MEMCTX_TASK, &imalloc);
|
||||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||||
@ -3065,6 +3077,9 @@ static void test_IMallocSpy(void)
|
|||||||
|
|
||||||
hr = CoRevokeMallocSpy();
|
hr = CoRevokeMallocSpy();
|
||||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||||
|
|
||||||
|
hr = CoRevokeMallocSpy();
|
||||||
|
ok(hr == CO_E_OBJNOTREG, "got 0x%08x\n", hr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void init_funcs(void)
|
static void init_funcs(void)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user