[PATCH 1/7] mciqtz32: Fix thread handle leak if a second play.

Akihiro Sagawa wine at gitlab.winehq.org
Mon Jul 4 07:59:56 CDT 2022


From: Akihiro Sagawa <sagawa.aki at gmail.com>

Signed-off-by: Akihiro Sagawa <sagawa.aki at gmail.com>
---
 dlls/mciqtz32/mciqtz.c | 11 +++++++----
 dlls/winmm/tests/mci.c |  5 +++++
 2 files changed, 12 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..786c79ea783 100644
--- a/dlls/winmm/tests/mci.c
+++ b/dlls/winmm/tests/mci.c
@@ -1320,6 +1320,11 @@ static void test_playWaveTypeMpegvideo(void)
     ok(status_parm.dwReturn == MCI_MODE_PLAY,
        "mciCommand status mode: %lu\n", (DWORD)status_parm.dwReturn);
 
+    /* a second play should be ignored */
+    err = mciSendStringA("play mysound", NULL, 0, NULL);
+    ok(!err,"mci play retuend %s\n", dbg_mcierr(err));
+
+    /* audio volume */
     err = mciSendStringA("setaudio mysound volume to 1000", NULL, 0, NULL);
     ok(!err,"mci setaudio volume to 1000 returned %s\n", dbg_mcierr(err));
 
-- 
GitLab


https://gitlab.winehq.org/wine/wine/-/merge_requests/370



More information about the wine-devel mailing list