[PATCH 5/5] mmdevapi: Fix reference leak in tests

Maarten Lankhorst m.b.lankhorst at gmail.com
Tue Jan 5 15:35:18 CST 2010


Found by Dan Kegel
---
 dlls/mmdevapi/tests/mmdevenum.c |   20 ++++++++++++--------
 1 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/dlls/mmdevapi/tests/mmdevenum.c b/dlls/mmdevapi/tests/mmdevenum.c
index 9e8e55c..35e0152 100644
--- a/dlls/mmdevapi/tests/mmdevenum.c
+++ b/dlls/mmdevapi/tests/mmdevenum.c
@@ -82,14 +82,18 @@ static void test_collection(IMMDeviceEnumerator *mme, IMMDeviceCollection *col)
     ok(hr == E_INVALIDARG, "Asking for too high device returned 0x%08x\n", hr);
     ok(dev == NULL, "Returned non-null device\n");
 
-    if (!numdev) return;
-    hr = IMMDeviceCollection_Item(col, 0, NULL);
-    ok(hr == E_POINTER, "Query with null pointer returned 0x%08x\n", hr);
-
-    hr = IMMDeviceCollection_Item(col, 0, &dev);
-    ok(hr == S_OK, "Valid Item returned 0x%08x\n", hr);
-    ok(dev != NULL, "Device is null!\n");
-    if (dev) IUnknown_Release(dev);
+    if (numdev)
+    {
+        hr = IMMDeviceCollection_Item(col, 0, NULL);
+        ok(hr == E_POINTER, "Query with null pointer returned 0x%08x\n", hr);
+
+        hr = IMMDeviceCollection_Item(col, 0, &dev);
+        ok(hr == S_OK, "Valid Item returned 0x%08x\n", hr);
+        ok(dev != NULL, "Device is null!\n");
+        if (dev)
+            IUnknown_Release(dev);
+    }
+    IUnknown_Release(col);
 }
 
 /* Only do parameter tests here, the actual MMDevice testing should be a separate test */
-- 
1.6.5.7


--------------030409030302060808010900--



More information about the wine-patches mailing list