msacm32: Add invalid parameter checks for acmFormatChoose().
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com> Signed-off-by: Andrew Eikum <aeikum@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
7fd7f6557e
commit
84e61e6a07
|
@ -288,6 +288,9 @@ MMRESULT WINAPI acmFormatChooseA(PACMFORMATCHOOSEA pafmtc)
|
|||
LPWSTR templ = NULL;
|
||||
DWORD sz;
|
||||
|
||||
if (pafmtc->cbStruct < sizeof(ACMFORMATCHOOSEA))
|
||||
return MMSYSERR_INVALPARAM;
|
||||
|
||||
afcw.cbStruct = sizeof(afcw);
|
||||
afcw.fdwStyle = pafmtc->fdwStyle;
|
||||
afcw.hwndOwner = pafmtc->hwndOwner;
|
||||
|
@ -359,6 +362,12 @@ done:
|
|||
*/
|
||||
MMRESULT WINAPI acmFormatChooseW(PACMFORMATCHOOSEW pafmtc)
|
||||
{
|
||||
if (pafmtc->cbStruct < sizeof(ACMFORMATCHOOSEW))
|
||||
return MMSYSERR_INVALPARAM;
|
||||
|
||||
if (!pafmtc->pwfx)
|
||||
return MMSYSERR_INVALPARAM;
|
||||
|
||||
if (pafmtc->fdwStyle & ACMFORMATCHOOSE_STYLEF_ENABLETEMPLATEHANDLE)
|
||||
return DialogBoxIndirectParamW(MSACM_hInstance32, (LPCDLGTEMPLATEW)pafmtc->hInstance,
|
||||
pafmtc->hwndOwner, FormatChooseDlgProc, (LPARAM)pafmtc);
|
||||
|
|
|
@ -1249,6 +1249,31 @@ static void test_acmFormatTagDetails(void)
|
|||
ok(aftd.cbFormatSize == sizeof(MPEGLAYER3WAVEFORMAT), "got %d\n", aftd.cbFormatSize);
|
||||
}
|
||||
|
||||
static void test_acmFormatChoose(void)
|
||||
{
|
||||
ACMFORMATCHOOSEW afc = {0};
|
||||
WAVEFORMATEX *pwfx;
|
||||
DWORD sizeMax;
|
||||
MMRESULT rc;
|
||||
|
||||
acmMetrics(NULL, ACM_METRIC_MAX_SIZE_FORMAT, &sizeMax);
|
||||
pwfx = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeMax);
|
||||
|
||||
afc.cbStruct = sizeof(afc);
|
||||
afc.pwfx = pwfx;
|
||||
|
||||
/* test invalid struct size */
|
||||
afc.cbStruct = sizeof(afc)-1;
|
||||
rc = acmFormatChooseW(&afc);
|
||||
ok(rc == MMSYSERR_INVALPARAM, "expected 0xb, got 0x%x\n", rc);
|
||||
afc.cbStruct = sizeof(afc);
|
||||
|
||||
afc.pwfx = NULL;
|
||||
rc = acmFormatChooseW(&afc);
|
||||
ok(rc == MMSYSERR_INVALPARAM, "expected 0xb, got 0x%x\n", rc);
|
||||
afc.pwfx = pwfx;
|
||||
}
|
||||
|
||||
static struct
|
||||
{
|
||||
struct
|
||||
|
@ -1418,6 +1443,7 @@ START_TEST(msacm)
|
|||
test_convert();
|
||||
test_acmFormatSuggest();
|
||||
test_acmFormatTagDetails();
|
||||
test_acmFormatChoose();
|
||||
/* Test acmDriverAdd in the end as it may conflict
|
||||
* with other tests due to codec lookup order */
|
||||
test_acmDriverAdd();
|
||||
|
|
Loading…
Reference in New Issue