Zebediah Figura : quartz: Free outstanding advise requests when destroying a system clock.

Alexandre Julliard julliard at winehq.org
Tue Jul 20 15:11:03 CDT 2021


Module: wine
Branch: master
Commit: 4e74fdcebeaf7a98ef72194fdd27ce5db85d2bda
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=4e74fdcebeaf7a98ef72194fdd27ce5db85d2bda

Author: Zebediah Figura <zfigura at codeweavers.com>
Date:   Mon Jul 19 22:25:27 2021 -0500

quartz: Free outstanding advise requests when destroying a system clock.

Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/quartz/systemclock.c       |  8 ++++++++
 dlls/quartz/tests/systemclock.c | 12 ++++++++++--
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/dlls/quartz/systemclock.c b/dlls/quartz/systemclock.c
index 597373a4112..73a923a7b99 100644
--- a/dlls/quartz/systemclock.c
+++ b/dlls/quartz/systemclock.c
@@ -90,6 +90,7 @@ static ULONG WINAPI system_clock_inner_Release(IUnknown *iface)
 {
     struct system_clock *clock = impl_from_IUnknown(iface);
     ULONG refcount = InterlockedDecrement(&clock->refcount);
+    struct advise_sink *sink, *cursor;
 
     TRACE("%p decreasing refcount to %u.\n", clock, refcount);
 
@@ -104,6 +105,13 @@ static ULONG WINAPI system_clock_inner_Release(IUnknown *iface)
             WaitForSingleObject(clock->thread, INFINITE);
             CloseHandle(clock->thread);
         }
+
+        LIST_FOR_EACH_ENTRY_SAFE(sink, cursor, &clock->sinks, struct advise_sink, entry)
+        {
+            list_remove(&sink->entry);
+            heap_free(sink);
+        }
+
         clock->cs.DebugInfo->Spare[0] = 0;
         DeleteCriticalSection(&clock->cs);
         heap_free(clock);
diff --git a/dlls/quartz/tests/systemclock.c b/dlls/quartz/tests/systemclock.c
index fa9464429f0..be5472ed6e1 100644
--- a/dlls/quartz/tests/systemclock.c
+++ b/dlls/quartz/tests/systemclock.c
@@ -272,11 +272,19 @@ static void test_advise(void)
     ok(hr == S_OK, "Got hr %#x.\n", hr);
     ok(WaitForSingleObject(semaphore, 200) == WAIT_TIMEOUT, "Semaphore should not be signaled.\n");
 
-    CloseHandle(event);
-    CloseHandle(semaphore);
+    ResetEvent(event);
+    hr = IReferenceClock_GetTime(clock, &current);
+    ok(SUCCEEDED(hr), "Got hr %#x.\n", hr);
+    hr = IReferenceClock_AdviseTime(clock, current, 500 * 10000, (HEVENT)event, &cookie);
+    ok(hr == S_OK, "Got hr %#x.\n", hr);
 
     ref = IReferenceClock_Release(clock);
     ok(!ref, "Got outstanding refcount %d.\n", ref);
+
+    ok(WaitForSingleObject(event, 0) == WAIT_TIMEOUT, "Event should not be signaled.\n");
+
+    CloseHandle(event);
+    CloseHandle(semaphore);
 }
 
 START_TEST(systemclock)




More information about the wine-cvs mailing list