Akihiro Sagawa : mciqtz32: Fix thread handle leak if a second play.

Alexandre Julliard julliard at winehq.org
Thu Jul 7 17:04:37 CDT 2022


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

Author: Akihiro Sagawa <sagawa.aki at gmail.com>
Date:   Tue Jul  5 21:02:49 2022 +0900

mciqtz32: Fix thread handle leak if a second play.

Signed-off-by: Akihiro Sagawa <sagawa.aki at gmail.com>

---

 dlls/mciqtz32/mciqtz.c | 11 +++++++----
 dlls/winmm/tests/mci.c | 13 +++++++++++++
 2 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/dlls/mciqtz32/mciqtz.c b/dlls/mciqtz32/mciqtz.c
index a7ec0b78f33..5bde3f5dd14 100644
--- a/dlls/mciqtz32/mciqtz.c
+++ b/dlls/mciqtz32/mciqtz.c
@@ -449,10 +449,13 @@ static DWORD MCIQTZ_mciPlay(UINT wDevID, DWORD dwFlags, LPMCI_PLAY_PARMS lpParms
 
     IVideoWindow_put_Visible(wma->vidwin, OATRUE);
 
-    wma->thread = CreateThread(NULL, 0, MCIQTZ_notifyThread, wma, 0, NULL);
-    if (!wma->thread) {
-        TRACE("Can't create thread\n");
-        return MCIERR_INTERNAL;
+    if (!wma->thread)
+    {
+        wma->thread = CreateThread(NULL, 0, MCIQTZ_notifyThread, wma, 0, NULL);
+        if (!wma->thread) {
+            TRACE("Can't create thread\n");
+            return MCIERR_INTERNAL;
+        }
     }
     return 0;
 }
diff --git a/dlls/winmm/tests/mci.c b/dlls/winmm/tests/mci.c
index cfad9a77da8..2e31cf51708 100644
--- a/dlls/winmm/tests/mci.c
+++ b/dlls/winmm/tests/mci.c
@@ -1336,6 +1336,19 @@ static void test_playWaveTypeMpegvideo(void)
 
     err = mciSendStringA("close mysound", NULL, 0, NULL);
     ok(!err,"mci close returned %s\n", dbg_mcierr(err));
+
+    /* test a second play */
+    err = mciSendStringA("open tempfile.wav type MPEGVideo alias mysound", NULL, 0, NULL);
+    ok(err==ok_saved,"mci open tempfile.wav type MPEGVideo returned %s\n", dbg_mcierr(err));
+
+    err = mciSendStringA("play mysound", NULL, 0, NULL);
+    ok(!err,"mci play retuend %s\n", dbg_mcierr(err));
+
+    err = mciSendStringA("play mysound", NULL, 0, NULL);
+    ok(!err,"mci play retuend %s\n", dbg_mcierr(err));
+
+    err = mciSendStringA("close mysound", NULL, 0, NULL);
+    ok(!err,"mci close returned %s\n", dbg_mcierr(err));
 }
 
 static void test_asyncWaveTypeMpegvideo(HWND hwnd)




More information about the wine-cvs mailing list