Sebastian Lackner : ole32: Verify arguments for CoWaitForMultipleHandles, always initialize index to zero.
Alexandre Julliard
julliard at wine.codeweavers.com
Fri Nov 21 09:11:39 CST 2014
Module: wine
Branch: master
Commit: bbf68910304b8a261e7dfdfad7f5d929cbb2dcd8
URL: http://source.winehq.org/git/wine.git/?a=commit;h=bbf68910304b8a261e7dfdfad7f5d929cbb2dcd8
Author: Sebastian Lackner <sebastian at fds-team.de>
Date: Wed Nov 5 00:39:51 2014 +0100
ole32: Verify arguments for CoWaitForMultipleHandles, always initialize index to zero.
---
dlls/ole32/compobj.c | 11 +++++++++++
dlls/ole32/tests/compobj.c | 13 -------------
2 files changed, 11 insertions(+), 13 deletions(-)
diff --git a/dlls/ole32/compobj.c b/dlls/ole32/compobj.c
index 1fab04f..1d9b943 100644
--- a/dlls/ole32/compobj.c
+++ b/dlls/ole32/compobj.c
@@ -4431,6 +4431,17 @@ HRESULT WINAPI CoWaitForMultipleHandles(DWORD dwFlags, DWORD dwTimeout,
TRACE("(0x%08x, 0x%08x, %d, %p, %p)\n", dwFlags, dwTimeout, cHandles,
pHandles, lpdwindex);
+ if (!lpdwindex)
+ return E_INVALIDARG;
+
+ *lpdwindex = 0;
+
+ if (!pHandles)
+ return E_INVALIDARG;
+
+ if (!cHandles)
+ return RPC_E_NO_SYNC;
+
while (TRUE)
{
DWORD now = GetTickCount();
diff --git a/dlls/ole32/tests/compobj.c b/dlls/ole32/tests/compobj.c
index f879773..38b21c9 100644
--- a/dlls/ole32/tests/compobj.c
+++ b/dlls/ole32/tests/compobj.c
@@ -2139,32 +2139,24 @@ static void test_CoWaitForMultipleHandles(void)
PostMessageA(hWnd, WM_DDE_FIRST, 0, 0);
hr = CoWaitForMultipleHandles(0, 50, 0, handles, NULL);
- todo_wine
ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
success = PeekMessageA(&msg, hWnd, WM_DDE_FIRST, WM_DDE_FIRST, PM_REMOVE);
- todo_wine
ok(success, "CoWaitForMultipleHandles unexpectedly pumped messages\n");
index = 0xdeadbeef;
PostMessageA(hWnd, WM_DDE_FIRST, 0, 0);
hr = CoWaitForMultipleHandles(0, 50, 0, NULL, &index);
- todo_wine
ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
- todo_wine
ok(index == 0, "expected index 0, got %u\n", index);
success = PeekMessageA(&msg, hWnd, WM_DDE_FIRST, WM_DDE_FIRST, PM_REMOVE);
- todo_wine
ok(success, "CoWaitForMultipleHandles unexpectedly pumped messages\n");
index = 0xdeadbeef;
PostMessageA(hWnd, WM_DDE_FIRST, 0, 0);
hr = CoWaitForMultipleHandles(0, 50, 0, handles, &index);
- todo_wine
ok(hr == RPC_E_NO_SYNC, "expected RPC_E_NO_SYNC, got 0x%08x\n", hr);
- todo_wine
ok(index == 0, "expected index 0, got %u\n", index);
success = PeekMessageA(&msg, hWnd, WM_DDE_FIRST, WM_DDE_FIRST, PM_REMOVE);
- todo_wine
ok(success, "CoWaitForMultipleHandles unexpectedly pumped messages\n");
index = 0xdeadbeef;
@@ -2187,7 +2179,6 @@ static void test_CoWaitForMultipleHandles(void)
PostMessageA(hWnd, WM_DDE_FIRST, 0, 0);
hr = CoWaitForMultipleHandles(0, 50, 2, handles, &index);
ok(hr == RPC_S_CALLPENDING, "expected RPC_S_CALLPENDING, got 0x%08x\n", hr);
- todo_wine
ok(index == 0 || broken(index == 0xdeadbeef) /* Win 8 */, "expected index 0, got %u\n", index);
success = PeekMessageA(&msg, hWnd, WM_DDE_FIRST, WM_DDE_FIRST, PM_REMOVE);
ok(!success, "CoWaitForMultipleHandles didn't pump any messages\n");
@@ -2209,7 +2200,6 @@ static void test_CoWaitForMultipleHandles(void)
PostMessageA(hWnd, WM_DDE_FIRST, 0, 0);
hr = CoWaitForMultipleHandles(0, 50, 2, handles, &index);
ok(hr == RPC_S_CALLPENDING, "expected RPC_S_CALLPENDING, got 0x%08x\n", hr);
- todo_wine
ok(index == 0 || broken(index == 0xdeadbeef) /* Win 8 */, "expected index 0, got %u\n", index);
success = PeekMessageA(&msg, hWnd, WM_DDE_FIRST, WM_DDE_FIRST, PM_REMOVE);
ok(!success, "CoWaitForMultipleHandles didn't pump any messages\n");
@@ -2239,7 +2229,6 @@ static void test_CoWaitForMultipleHandles(void)
PostMessageA(hWnd, WM_DDE_FIRST, 0, 0);
hr = CoWaitForMultipleHandles(COWAIT_ALERTABLE, 50, 2, handles, &index);
ok(hr == RPC_S_CALLPENDING, "expected RPC_S_CALLPENDING, got 0x%08x\n", hr);
- todo_wine
ok(index == 0 || broken(index == 0xdeadbeef) /* Win 8 */, "expected index 0, got %u\n", index);
success = PeekMessageA(&msg, hWnd, WM_DDE_FIRST, WM_DDE_FIRST, PM_REMOVE);
ok(!success, "CoWaitForMultipleHandles didn't pump any messages\n");
@@ -2263,7 +2252,6 @@ static void test_CoWaitForMultipleHandles(void)
ok(success, "PeekMessageA returned FALSE\n");
hr = CoWaitForMultipleHandles(0, 50, 2, handles, &index);
ok(hr == RPC_S_CALLPENDING, "expected RPC_S_CALLPENDING, got 0x%08x\n", hr);
- todo_wine
ok(index == 0 || broken(index == 0xdeadbeef) /* Win 8 */, "expected index 0, got %u\n", index);
success = PeekMessageA(&msg, hWnd, WM_DDE_FIRST, WM_DDE_FIRST, PM_REMOVE);
ok(!success, "CoWaitForMultipleHandles didn't pump any messages\n");
@@ -2278,7 +2266,6 @@ static void test_CoWaitForMultipleHandles(void)
ok(hr == RPC_S_CALLPENDING || broken(hr == E_INVALIDARG) || broken(hr == S_OK) /* Win 8 */,
"expected RPC_S_CALLPENDING, got 0x%08x\n", hr);
ReleaseSemaphore(handles[1], 1, NULL);
- todo_wine
ok(index == 0 || broken(index == 1) /* Win 8 */, "expected index 0, got %u\n", index);
success = PeekMessageA(&msg, hWnd, WM_DDE_FIRST, WM_DDE_FIRST, PM_REMOVE);
ok(!success || broken(success && hr == E_INVALIDARG),
More information about the wine-cvs
mailing list