Fixes: caa41d4917a84dbbeb4aa14f18cfecfd17efe71a Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49659 Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/msdmo/dmoreg.c | 20 +++++++++++++----- dlls/msdmo/tests/msdmo.c | 44 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 5 deletions(-)
diff --git a/dlls/msdmo/dmoreg.c b/dlls/msdmo/dmoreg.c index 8e0680931f4..33caa6d0dc5 100644 --- a/dlls/msdmo/dmoreg.c +++ b/dlls/msdmo/dmoreg.c @@ -526,11 +526,16 @@ static HRESULT WINAPI IEnumDMO_fnNext(
if (This->pInTypes) { - DWORD size = types_size, i; + DWORD size, i;
- while ((ret = RegQueryValueExW(hkey, L"InputTypes", NULL, NULL, - (BYTE *)types, &size)) == ERROR_MORE_DATA) + for (;;) { + size = types_size; + ret = RegQueryValueExW(hkey, L"InputTypes", NULL, NULL, (BYTE *)types, &size); + if (ret != ERROR_SUCCESS && ret != ERROR_MORE_DATA) + break; + if (size <= types_size) + break; if (!array_reserve((void **)&types, &types_size, size, 1)) { RegCloseKey(hkey); @@ -559,9 +564,14 @@ static HRESULT WINAPI IEnumDMO_fnNext( { DWORD size = types_size, i;
- while ((ret = RegQueryValueExW(hkey, L"OutputTypes", NULL, NULL, - (BYTE *)types, &size)) == ERROR_MORE_DATA) + for (;;) { + size = types_size; + ret = RegQueryValueExW(hkey, L"OutputTypes", NULL, NULL, (BYTE *)types, &size); + if (ret != ERROR_SUCCESS && ret != ERROR_MORE_DATA) + break; + if (size <= types_size) + break; if (!array_reserve((void **)&types, &types_size, size, 1)) { RegCloseKey(hkey); diff --git a/dlls/msdmo/tests/msdmo.c b/dlls/msdmo/tests/msdmo.c index a1ab8ee00dc..b1b2f544ceb 100644 --- a/dlls/msdmo/tests/msdmo.c +++ b/dlls/msdmo/tests/msdmo.c @@ -88,6 +88,9 @@ static void test_DMOGetName(void)
static void test_DMOEnum(void) { + static const DMO_PARTIAL_MEDIATYPE input_type = {{0x1111}, {0x2222}}; + static const DMO_PARTIAL_MEDIATYPE wrong_type = {{0x3333}, {0x4444}}; + IEnumDMO *enum_dmo; HRESULT hr; CLSID clsid; @@ -115,6 +118,47 @@ static void test_DMOEnum(void) ok(count == 0, "expected 0, got %d\n", count);
IEnumDMO_Release(enum_dmo); + + hr = DMORegister(L"testdmo", &GUID_unknowndmo, &GUID_unknowncategory, 0, 1, &input_type, 0, NULL); + if (hr != S_OK) + return; + + hr = DMOEnum(&GUID_unknowncategory, 0, 0, NULL, 0, NULL, &enum_dmo); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IEnumDMO_Next(enum_dmo, 1, &clsid, &name, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(IsEqualGUID(&clsid, &GUID_unknowndmo), "Got clsid %s.\n", debugstr_guid(&clsid)); + ok(!wcscmp(name, L"testdmo"), "Got name %s.\n", debugstr_w(name)); + + hr = IEnumDMO_Next(enum_dmo, 1, &clsid, &name, NULL); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + IEnumDMO_Release(enum_dmo); + + hr = DMOEnum(&GUID_unknowncategory, 0, 1, &input_type, 0, NULL, &enum_dmo); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IEnumDMO_Next(enum_dmo, 1, &clsid, &name, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(IsEqualGUID(&clsid, &GUID_unknowndmo), "Got clsid %s.\n", debugstr_guid(&clsid)); + ok(!wcscmp(name, L"testdmo"), "Got name %s.\n", debugstr_w(name)); + + hr = IEnumDMO_Next(enum_dmo, 1, &clsid, &name, NULL); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + IEnumDMO_Release(enum_dmo); + + hr = DMOEnum(&GUID_unknowncategory, 0, 1, &wrong_type, 0, NULL, &enum_dmo); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IEnumDMO_Next(enum_dmo, 1, &clsid, &name, NULL); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + IEnumDMO_Release(enum_dmo); + + hr = DMOUnregister(&GUID_unknowndmo, &GUID_unknowncategory); + ok(hr == S_OK, "Got hr %#x.\n", hr); }
static void test_DMOGetTypes(void)