winmm: Fix wave test handle use after close bug.

This commit is contained in:
Robert Reif 2006-05-19 07:34:08 -04:00 committed by Alexandre Julliard
parent 94cc17b53c
commit ed62b0150c
1 changed files with 12 additions and 3 deletions

View File

@ -534,8 +534,13 @@ static DWORD WINAPI callback_thread(LPVOID lpParameter)
{ {
MSG msg; MSG msg;
while (GetMessage(&msg, 0, 0, 0)) while (GetMessage(&msg, 0, 0, 0)) {
UINT message = msg.message;
ok (message == WOM_OPEN || message == WOM_DONE || message == WOM_CLOSE,
"GetMessage returned unexpected message: %u\n", message);
if (message == WOM_OPEN || message == WOM_DONE || message == WOM_CLOSE)
SetEvent((HANDLE)lpParameter); SetEvent((HANDLE)lpParameter);
}
return 0; return 0;
} }
@ -579,16 +584,20 @@ static void wave_out_test_deviceOut(int device, double duration,
callback_instance = 0; callback_instance = 0;
} else { } else {
trace("CreateThread() failed\n"); trace("CreateThread() failed\n");
CloseHandle(hevent);
return; return;
} }
} else if ((flags & CALLBACK_TYPEMASK) == CALLBACK_WINDOW) { } else if ((flags & CALLBACK_TYPEMASK) == CALLBACK_WINDOW) {
trace("CALLBACK_THREAD not implemented\n"); trace("CALLBACK_THREAD not implemented\n");
CloseHandle(hevent);
return; return;
} else if (flags && CALLBACK_TYPEMASK) { } else if (flags && CALLBACK_TYPEMASK) {
trace("Undefined callback type!\n"); trace("Undefined callback type!\n");
CloseHandle(hevent);
return; return;
} else { } else {
trace("CALLBACK_NULL not implemented\n"); trace("CALLBACK_NULL not implemented\n");
CloseHandle(hevent);
return; return;
} }
wout=NULL; wout=NULL;
@ -728,12 +737,12 @@ static void wave_out_test_deviceOut(int device, double duration,
wave_out_error(rc)); wave_out_error(rc));
free(frag.lpData); free(frag.lpData);
CloseHandle(hevent);
rc=waveOutClose(wout); rc=waveOutClose(wout);
ok(rc==MMSYSERR_NOERROR,"waveOutClose(%s): rc=%s\n",dev_name(device), ok(rc==MMSYSERR_NOERROR,"waveOutClose(%s): rc=%s\n",dev_name(device),
wave_out_error(rc)); wave_out_error(rc));
if ((flags & CALLBACK_TYPEMASK) == CALLBACK_THREAD) if ((flags & CALLBACK_TYPEMASK) == CALLBACK_THREAD)
TerminateThread(thread, 0); TerminateThread(thread, 0);
CloseHandle(hevent);
} }
static void wave_out_test_device(int device) static void wave_out_test_device(int device)