Commit 438c7489 authored by Ken Thomases's avatar Ken Thomases Committed by Alexandre Julliard

winecoreaudio: Improve safety of iterations when returning WAVEHDRs to client.

parent 1b4ad056
...@@ -1059,12 +1059,16 @@ static void wodHelper_PlayPtrNext(WINE_WAVEOUT* wwo) ...@@ -1059,12 +1059,16 @@ static void wodHelper_PlayPtrNext(WINE_WAVEOUT* wwo)
*/ */
static void wodHelper_NotifyDoneForList(WINE_WAVEOUT* wwo, LPWAVEHDR lpWaveHdr) static void wodHelper_NotifyDoneForList(WINE_WAVEOUT* wwo, LPWAVEHDR lpWaveHdr)
{ {
for ( ; lpWaveHdr; lpWaveHdr = lpWaveHdr->lpNext) while (lpWaveHdr)
{ {
LPWAVEHDR lpNext = lpWaveHdr->lpNext;
lpWaveHdr->lpNext = NULL;
lpWaveHdr->dwFlags &= ~WHDR_INQUEUE; lpWaveHdr->dwFlags &= ~WHDR_INQUEUE;
lpWaveHdr->dwFlags |= WHDR_DONE; lpWaveHdr->dwFlags |= WHDR_DONE;
wodNotifyClient(wwo, WOM_DONE, (DWORD)lpWaveHdr, 0); wodNotifyClient(wwo, WOM_DONE, (DWORD)lpWaveHdr, 0);
lpWaveHdr = lpNext;
} }
} }
...@@ -1670,12 +1674,17 @@ static void widHelper_NotifyCompletions(WINE_WAVEIN* wwi) ...@@ -1670,12 +1674,17 @@ static void widHelper_NotifyCompletions(WINE_WAVEIN* wwi)
OSSpinLockUnlock(&wwi->lock); OSSpinLockUnlock(&wwi->lock);
/* Now, send the "done" notification for each header in our list. */ /* Now, send the "done" notification for each header in our list. */
for (lpWaveHdr = lpFirstDoneWaveHdr; lpWaveHdr; lpWaveHdr = lpWaveHdr->lpNext) lpWaveHdr = lpFirstDoneWaveHdr;
while (lpWaveHdr)
{ {
LPWAVEHDR lpNext = lpWaveHdr->lpNext;
lpWaveHdr->lpNext = NULL;
lpWaveHdr->dwFlags &= ~WHDR_INQUEUE; lpWaveHdr->dwFlags &= ~WHDR_INQUEUE;
lpWaveHdr->dwFlags |= WHDR_DONE; lpWaveHdr->dwFlags |= WHDR_DONE;
widNotifyClient(wwi, WIM_DATA, (DWORD)lpWaveHdr, 0); widNotifyClient(wwi, WIM_DATA, (DWORD)lpWaveHdr, 0);
lpWaveHdr = lpNext;
} }
} }
...@@ -2074,6 +2083,7 @@ static DWORD widStop(WORD wDevID) ...@@ -2074,6 +2083,7 @@ static DWORD widStop(WORD wDevID)
if (lpWaveHdr) if (lpWaveHdr)
{ {
lpWaveHdr->lpNext = NULL;
lpWaveHdr->dwFlags &= ~WHDR_INQUEUE; lpWaveHdr->dwFlags &= ~WHDR_INQUEUE;
lpWaveHdr->dwFlags |= WHDR_DONE; lpWaveHdr->dwFlags |= WHDR_DONE;
widNotifyClient(wwi, WIM_DATA, (DWORD)lpWaveHdr, 0); widNotifyClient(wwi, WIM_DATA, (DWORD)lpWaveHdr, 0);
...@@ -2130,6 +2140,7 @@ static DWORD widReset(WORD wDevID) ...@@ -2130,6 +2140,7 @@ static DWORD widReset(WORD wDevID)
{ {
WAVEHDR* lpNext = lpWaveHdr->lpNext; WAVEHDR* lpNext = lpWaveHdr->lpNext;
lpWaveHdr->lpNext = NULL;
lpWaveHdr->dwFlags &= ~WHDR_INQUEUE; lpWaveHdr->dwFlags &= ~WHDR_INQUEUE;
lpWaveHdr->dwFlags |= WHDR_DONE; lpWaveHdr->dwFlags |= WHDR_DONE;
widNotifyClient(wwi, WIM_DATA, (DWORD)lpWaveHdr, 0); widNotifyClient(wwi, WIM_DATA, (DWORD)lpWaveHdr, 0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment