Nikolay Sivov : ole32: Fix parameter validation for CoGetMalloc().
Alexandre Julliard
julliard at wine.codeweavers.com
Wed Dec 23 18:22:08 CST 2015
Module: wine
Branch: master
Commit: 12d73316e475202803680a59ab60939d234120f6
URL: http://source.winehq.org/git/wine.git/?a=commit;h=12d73316e475202803680a59ab60939d234120f6
Author: Nikolay Sivov <nsivov at codeweavers.com>
Date: Wed Dec 23 00:36:45 2015 +0300
ole32: Fix parameter validation for CoGetMalloc().
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/ole32/ifs.c | 15 ++++++++++-----
dlls/ole32/tests/compobj.c | 15 +++++----------
2 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/dlls/ole32/ifs.c b/dlls/ole32/ifs.c
index 696a7b8..18fd1fd 100644
--- a/dlls/ole32/ifs.c
+++ b/dlls/ole32/ifs.c
@@ -368,17 +368,22 @@ static const IMallocVtbl VT_IMalloc32 =
* Retrieves the current IMalloc interface for the process.
*
* PARAMS
- * dwMemContext [I]
- * lpMalloc [O] Address where memory allocator object will be stored.
+ * context [I] Should always be MEMCTX_TASK.
+ * imalloc [O] Address where memory allocator object will be stored.
*
* RETURNS
* Success: S_OK.
* Failure: HRESULT code.
*/
-HRESULT WINAPI CoGetMalloc(DWORD dwMemContext, LPMALLOC *lpMalloc)
+HRESULT WINAPI CoGetMalloc(DWORD context, IMalloc **imalloc)
{
- *lpMalloc = &Malloc32.IMalloc_iface;
- return S_OK;
+ if (context != MEMCTX_TASK) {
+ *imalloc = NULL;
+ return E_INVALIDARG;
+ }
+
+ *imalloc = &Malloc32.IMalloc_iface;
+ return S_OK;
}
/***********************************************************************
diff --git a/dlls/ole32/tests/compobj.c b/dlls/ole32/tests/compobj.c
index 10eb2fa..1913e1f 100644
--- a/dlls/ole32/tests/compobj.c
+++ b/dlls/ole32/tests/compobj.c
@@ -2629,34 +2629,29 @@ if (0) /* crashes on native */
imalloc = (void*)0xdeadbeef;
hr = CoGetMalloc(0, &imalloc);
-todo_wine {
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
ok(imalloc == NULL, "got %p\n", imalloc);
-}
+
imalloc = (void*)0xdeadbeef;
hr = CoGetMalloc(MEMCTX_SHARED, &imalloc);
-todo_wine {
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
ok(imalloc == NULL, "got %p\n", imalloc);
-}
+
imalloc = (void*)0xdeadbeef;
hr = CoGetMalloc(MEMCTX_MACSYSTEM, &imalloc);
-todo_wine {
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
ok(imalloc == NULL, "got %p\n", imalloc);
-}
+
imalloc = (void*)0xdeadbeef;
hr = CoGetMalloc(MEMCTX_UNKNOWN, &imalloc);
-todo_wine {
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
ok(imalloc == NULL, "got %p\n", imalloc);
-}
+
imalloc = (void*)0xdeadbeef;
hr = CoGetMalloc(MEMCTX_SAME, &imalloc);
-todo_wine {
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
ok(imalloc == NULL, "got %p\n", imalloc);
-}
+
imalloc = NULL;
hr = CoGetMalloc(MEMCTX_TASK, &imalloc);
ok(hr == S_OK, "got 0x%08x\n", hr);
More information about the wine-cvs
mailing list