[PATCH 2/4] msdmo: Fix pointer checking in IEnumDMO_Next().

Zebediah Figura z.figura12 at gmail.com
Tue May 8 18:55:00 CDT 2018


Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
 dlls/msdmo/dmoreg.c      | 9 ++++++---
 dlls/msdmo/tests/msdmo.c | 9 ++++++++-
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/dlls/msdmo/dmoreg.c b/dlls/msdmo/dmoreg.c
index 43b0438..255849d3d 100644
--- a/dlls/msdmo/dmoreg.c
+++ b/dlls/msdmo/dmoreg.c
@@ -519,9 +519,12 @@ static HRESULT WINAPI IEnumDMO_fnNext(
 
     TRACE("(%p)->(%d %p %p %p)\n", This, cItemsToFetch, pCLSID, Names, pcItemsFetched);
 
-    if (!pCLSID || !Names || !pcItemsFetched)
+    if (!pCLSID || !Names)
         return E_POINTER;
 
+    if (!pcItemsFetched && cItemsToFetch > 1)
+        return E_INVALIDARG;
+
     while (count < cItemsToFetch)
     {
         This->index++;
@@ -656,8 +659,8 @@ static HRESULT WINAPI IEnumDMO_fnNext(
 	count++;
     }
 
-    *pcItemsFetched = count;
-    if (*pcItemsFetched < cItemsToFetch)
+    if (pcItemsFetched) *pcItemsFetched = count;
+    if (count < cItemsToFetch)
         hres = S_FALSE;
 
     TRACE("<-- %i found\n",count);
diff --git a/dlls/msdmo/tests/msdmo.c b/dlls/msdmo/tests/msdmo.c
index 32d79ce..a78ee83 100644
--- a/dlls/msdmo/tests/msdmo.c
+++ b/dlls/msdmo/tests/msdmo.c
@@ -92,14 +92,21 @@ static void test_DMOEnum(void)
     HRESULT hr;
     CLSID clsid;
     WCHAR *name;
+    DWORD count;
 
     hr = DMOEnum(&GUID_unknowncategory, 0, 0, NULL, 0, NULL, &enum_dmo);
     ok(hr == S_OK, "DMOEnum() failed with %#x\n", hr);
 
     hr = IEnumDMO_Next(enum_dmo, 1, &clsid, &name, NULL);
-    todo_wine
     ok(hr == S_FALSE, "expected S_FALSE, got %#x\n", hr);
 
+    hr = IEnumDMO_Next(enum_dmo, 2, &clsid, &name, NULL);
+    ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got %#x\n", hr);
+
+    hr = IEnumDMO_Next(enum_dmo, 2, &clsid, &name, &count);
+    ok(hr == S_FALSE, "expected S_FALSE, got %#x\n", hr);
+    ok(count == 0, "expected 0, got %d\n", count);
+
     IEnumDMO_Release(enum_dmo);
 }
 
-- 
2.7.4




More information about the wine-devel mailing list