https://git.reactos.org/?p=reactos.git;a=commitdiff;h=8c5cacf8a0970ee2423b3…
commit 8c5cacf8a0970ee2423b3504a123d5a06bc09ea4
Author: Thamatip Chitpong <tangaming123456(a)outlook.com>
AuthorDate: Wed Jun 14 08:31:05 2023 +0700
Commit: Stanislav Motylkov <x86corez(a)gmail.com>
CommitDate: Thu Jul 6 13:36:20 2023 +0300
[WINESYNC][WINMM] PlaySound concurrency cleanup
Wine commit: e0dcc2cd7d4495b7056a47ada1af74cc7c318ef2
author: Jörg Höhle <hoehle(a)users.sourceforge.net>
Mon, 28 Mar 2011 20:34:02 +0000 (22:34 +0200)
committer: Alexandre Julliard <julliard(a)winehq.org>
Wed, 30 Mar 2011 11:28:04 +0000 (13:28 +0200)
---
dll/win32/winmm/playsound.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/dll/win32/winmm/playsound.c b/dll/win32/winmm/playsound.c
index d0819b65f9b..c41479d187f 100644
--- a/dll/win32/winmm/playsound.c
+++ b/dll/win32/winmm/playsound.c
@@ -452,6 +452,8 @@ static BOOL proc_PlaySound(WINE_PLAYSOUND *wps)
(LPSTR)&mmckInfo.ckid, mmckInfo.fccType, mmckInfo.cksize);
lpWaveFormat = HeapAlloc(GetProcessHeap(), 0, mmckInfo.cksize);
+ if (!lpWaveFormat)
+ goto errCleanUp;
if (mmioRead(wps->hmmio, (HPSTR)lpWaveFormat, mmckInfo.cksize) <
sizeof(PCMWAVEFORMAT))
goto errCleanUp;
@@ -473,6 +475,8 @@ static BOOL proc_PlaySound(WINE_PLAYSOUND *wps)
(LPSTR)&mmckInfo.ckid, mmckInfo.fccType, mmckInfo.cksize);
s.hEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
+ if (!s.hEvent)
+ goto errCleanUp;
if (waveOutOpen(&hWave, WAVE_MAPPER, lpWaveFormat,
(DWORD_PTR)PlaySound_Callback,
(DWORD_PTR)&s, CALLBACK_FUNCTION) != MMSYSERR_NOERROR)
@@ -482,6 +486,8 @@ static BOOL proc_PlaySound(WINE_PLAYSOUND *wps)
bufsize = (((lpWaveFormat->nAvgBytesPerSec / 3) - 1) /
lpWaveFormat->nBlockAlign + 1) *
lpWaveFormat->nBlockAlign;
waveHdr = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(WAVEHDR) + 2 * bufsize);
+ if (!waveHdr)
+ goto errCleanUp;
waveHdr[0].lpData = (char*)waveHdr + 2 * sizeof(WAVEHDR);
waveHdr[1].lpData = (char*)waveHdr + 2 * sizeof(WAVEHDR) + bufsize;
waveHdr[0].dwUser = waveHdr[1].dwUser = 0L;
@@ -533,10 +539,10 @@ static BOOL proc_PlaySound(WINE_PLAYSOUND *wps)
errCleanUp:
TRACE("Done playing sound => %s!\n", bRet ? "ok" :
"ko");
- CloseHandle(s.hEvent);
- HeapFree(GetProcessHeap(), 0, waveHdr);
HeapFree(GetProcessHeap(), 0, lpWaveFormat);
if (hWave) while (waveOutClose(hWave) == WAVERR_STILLPLAYING) Sleep(100);
+ CloseHandle(s.hEvent);
+ HeapFree(GetProcessHeap(), 0, waveHdr);
PlaySound_Free(wps);
@@ -611,7 +617,7 @@ static BOOL MULTIMEDIA_PlaySound(const void* pszSound, HMODULE hmod,
DWORD fdwSo
PlaySoundList = wps;
LeaveCriticalSection(&WINMM_cs);
- if (!pszSound || (fdwSound & SND_PURGE)) return TRUE;
+ if (!wps) return TRUE;
if (fdwSound & SND_ASYNC)
{