Commit 7000af55 authored by Fabian Maurer's avatar Fabian Maurer Committed by Alexandre Julliard

winmm: Don't crash in waveOutOpen when nSamplesPerSec is 0 and add tests.

parent 9e516ba1
......@@ -1415,6 +1415,28 @@ static void wave_out_test_device(UINT_PTR device)
} else
trace("waveOutOpen(%s): 32 bit float samples not supported\n",
dev_name(device));
/* Test invalid parameters */
format.wFormatTag = WAVE_FORMAT_PCM;
format.nChannels = 1;
format.nSamplesPerSec = 11025;
format.nBlockAlign = 1;
format.nAvgBytesPerSec = 11025 * 1;
format.wBitsPerSample = 8;
format.cbSize = 0;
format.nAvgBytesPerSec = 0;
rc = waveOutOpen(&wout, device, &format, 0, 0, 0);
ok(rc == MMSYSERR_NOERROR,
"waveOutOpen(%s): returned %s\n",dev_name(device),wave_out_error(rc));
waveOutClose(wout);
format.nAvgBytesPerSec = 11025 * 1;
format.nSamplesPerSec = 0;
rc = waveOutOpen(&wout, device, &format, 0, 0, 0);
ok(rc == MMSYSERR_INVALPARAM || rc == WAVERR_BADFORMAT, /* XP and lower return WAVERR_BADFORMAT */
"waveOutOpen(%s): returned %s\n",dev_name(device),wave_out_error(rc));
}
static void wave_out_tests(void)
......
......@@ -1088,6 +1088,13 @@ static LRESULT WINMM_OpenDevice(WINMM_Device *device, WINMM_OpenInfo *info,
}
if(info->format->wFormatTag == WAVE_FORMAT_PCM){
if (info->format->nSamplesPerSec == 0)
{
ret = MMSYSERR_INVALPARAM;
goto error;
}
/* we aren't guaranteed that the struct in lpFormat is a full
* WAVEFORMATEX struct, which IAC::IsFormatSupported requires */
device->orig_fmt = HeapAlloc(GetProcessHeap(), 0, sizeof(WAVEFORMATEX));
......
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