Commit 12d73316 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

ole32: Fix parameter validation for CoGetMalloc().

parent f6bfc309
...@@ -368,17 +368,22 @@ static const IMallocVtbl VT_IMalloc32 = ...@@ -368,17 +368,22 @@ static const IMallocVtbl VT_IMalloc32 =
* Retrieves the current IMalloc interface for the process. * Retrieves the current IMalloc interface for the process.
* *
* PARAMS * PARAMS
* dwMemContext [I] * context [I] Should always be MEMCTX_TASK.
* lpMalloc [O] Address where memory allocator object will be stored. * imalloc [O] Address where memory allocator object will be stored.
* *
* RETURNS * RETURNS
* Success: S_OK. * Success: S_OK.
* Failure: HRESULT code. * Failure: HRESULT code.
*/ */
HRESULT WINAPI CoGetMalloc(DWORD dwMemContext, LPMALLOC *lpMalloc) HRESULT WINAPI CoGetMalloc(DWORD context, IMalloc **imalloc)
{ {
*lpMalloc = &Malloc32.IMalloc_iface; if (context != MEMCTX_TASK) {
return S_OK; *imalloc = NULL;
return E_INVALIDARG;
}
*imalloc = &Malloc32.IMalloc_iface;
return S_OK;
} }
/*********************************************************************** /***********************************************************************
......
...@@ -2629,34 +2629,29 @@ if (0) /* crashes on native */ ...@@ -2629,34 +2629,29 @@ if (0) /* crashes on native */
imalloc = (void*)0xdeadbeef; imalloc = (void*)0xdeadbeef;
hr = CoGetMalloc(0, &imalloc); hr = CoGetMalloc(0, &imalloc);
todo_wine {
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
ok(imalloc == NULL, "got %p\n", imalloc); ok(imalloc == NULL, "got %p\n", imalloc);
}
imalloc = (void*)0xdeadbeef; imalloc = (void*)0xdeadbeef;
hr = CoGetMalloc(MEMCTX_SHARED, &imalloc); hr = CoGetMalloc(MEMCTX_SHARED, &imalloc);
todo_wine {
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
ok(imalloc == NULL, "got %p\n", imalloc); ok(imalloc == NULL, "got %p\n", imalloc);
}
imalloc = (void*)0xdeadbeef; imalloc = (void*)0xdeadbeef;
hr = CoGetMalloc(MEMCTX_MACSYSTEM, &imalloc); hr = CoGetMalloc(MEMCTX_MACSYSTEM, &imalloc);
todo_wine {
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
ok(imalloc == NULL, "got %p\n", imalloc); ok(imalloc == NULL, "got %p\n", imalloc);
}
imalloc = (void*)0xdeadbeef; imalloc = (void*)0xdeadbeef;
hr = CoGetMalloc(MEMCTX_UNKNOWN, &imalloc); hr = CoGetMalloc(MEMCTX_UNKNOWN, &imalloc);
todo_wine {
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
ok(imalloc == NULL, "got %p\n", imalloc); ok(imalloc == NULL, "got %p\n", imalloc);
}
imalloc = (void*)0xdeadbeef; imalloc = (void*)0xdeadbeef;
hr = CoGetMalloc(MEMCTX_SAME, &imalloc); hr = CoGetMalloc(MEMCTX_SAME, &imalloc);
todo_wine {
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
ok(imalloc == NULL, "got %p\n", imalloc); ok(imalloc == NULL, "got %p\n", imalloc);
}
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);
......
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