More parameter checking fixes with tests.

This commit is contained in:
Robert Reif 2004-05-10 19:56:53 +00:00 committed by Alexandre Julliard
parent 426b02362b
commit 321189aa21
3 changed files with 66 additions and 4 deletions

View File

@ -741,6 +741,15 @@ MMRESULT WINAPI acmFormatTagEnumA(HACMDRIVER had, PACMFORMATTAGDETAILSA paftda,
ACMFORMATTAGDETAILSW aftdw;
struct MSACM_FormatTagEnumWtoA_Instance aftei;
if (!paftda)
return MMSYSERR_INVALPARAM;
if (paftda->cbStruct < sizeof(*paftda))
return MMSYSERR_INVALPARAM;
if (fdwEnum != 0)
return MMSYSERR_INVALFLAG;
memset(&aftdw, 0, sizeof(aftdw));
aftdw.cbStruct = sizeof(aftdw);
aftdw.dwFormatTagIndex = paftda->dwFormatTagIndex;
@ -768,7 +777,14 @@ MMRESULT WINAPI acmFormatTagEnumW(HACMDRIVER had, PACMFORMATTAGDETAILSW paftd,
TRACE("(%p, %p, %p, %ld, %ld)\n",
had, paftd, fnCallback, dwInstance, fdwEnum);
if (paftd->cbStruct < sizeof(*paftd)) return MMSYSERR_INVALPARAM;
if (!paftd)
return MMSYSERR_INVALPARAM;
if (paftd->cbStruct < sizeof(*paftd))
return MMSYSERR_INVALPARAM;
if (fdwEnum != 0)
return MMSYSERR_INVALFLAG;
/* (WS) MSDN info page says that if had != 0, then we should find
* the specific driver to get its tags from. Therefore I'm removing

View File

@ -960,7 +960,7 @@ static LRESULT PCM_FormatSuggest(PACMDRVFORMATSUGGEST adfs)
if (adfs->pwfxSrc->wFormatTag != WAVE_FORMAT_PCM) {
WARN("not possible\n");
return ACMERR_NOTPOSSIBLE;
}
}
adfs->pwfxDst->wFormatTag = adfs->pwfxSrc->wFormatTag;
}
/* check if result is ok */

View File

@ -31,6 +31,16 @@
#include "mmreg.h"
#include "msacm.h"
static BOOL CALLBACK FormatTagEnumProc(HACMDRIVERID hadid,
PACMFORMATTAGDETAILS paftd,
DWORD dwInstance,
DWORD fdwSupport)
{
trace(" Format 0x%04lx: %s\n", paftd->dwFormatTag, paftd->szFormatTag);
return TRUE;
}
static BOOL CALLBACK FormatEnumProc(HACMDRIVERID hadid,
LPACMFORMATDETAILS pafd,
DWORD dwInstance,
@ -141,8 +151,6 @@ static BOOL CALLBACK DriverEnumProc(HACMDRIVERID hadid,
if (rc == MMSYSERR_NOERROR) {
DWORD dwSize;
WAVEFORMATEX * pwfx;
ACMFORMATDETAILS fd;
HACMDRIVERID hid;
/* try bad pointer */
@ -202,6 +210,10 @@ static BOOL CALLBACK DriverEnumProc(HACMDRIVERID hadid,
"acmMetrics(): rc = %08x, should be %08x\n",
rc, MMSYSERR_NOERROR);
if (rc == MMSYSERR_NOERROR) {
ACMFORMATDETAILS fd;
WAVEFORMATEX * pwfx;
ACMFORMATTAGDETAILS aftd;
/* try bad pointer */
rc = acmFormatEnum(had, 0, FormatEnumProc, 0, 0);
ok(rc == MMSYSERR_INVALPARAM,
@ -241,6 +253,40 @@ static BOOL CALLBACK DriverEnumProc(HACMDRIVERID hadid,
"acmFormatEnum(): rc = %08x, should be %08x\n",
rc, MMSYSERR_NOERROR);
/* try bad pointer */
rc = acmFormatTagEnum(had, 0, FormatTagEnumProc, 0, 0);
ok(rc == MMSYSERR_INVALPARAM,
"acmFormatTagEnum(): rc = %08x, should be %08x\n",
rc, MMSYSERR_INVALPARAM);
/* try bad structure size */
ZeroMemory(&aftd, sizeof(fd));
rc = acmFormatTagEnum(had, &aftd, FormatTagEnumProc, 0, 0);
ok(rc == MMSYSERR_INVALPARAM,
"acmFormatTagEnum(): rc = %08x, should be %08x\n",
rc, MMSYSERR_INVALPARAM);
aftd.cbStruct = sizeof(aftd) - 1;
rc = acmFormatTagEnum(had, &aftd, FormatTagEnumProc, 0, 0);
ok(rc == MMSYSERR_INVALPARAM,
"acmFormatTagEnum(): rc = %08x, should be %08x\n",
rc, MMSYSERR_INVALPARAM);
aftd.cbStruct = sizeof(aftd);
aftd.dwFormatTag = WAVE_FORMAT_UNKNOWN;
/* try bad flag */
rc = acmFormatTagEnum(had, &aftd, FormatTagEnumProc, 0, 1);
ok(rc == MMSYSERR_INVALFLAG,
"acmFormatTagEnum(): rc = %08x, should be %08x\n",
rc, MMSYSERR_INVALFLAG);
/* try valid parameters */
rc = acmFormatTagEnum(had, &aftd, FormatTagEnumProc, 0, 0);
ok(rc == MMSYSERR_NOERROR,
"acmFormatTagEnum(): rc = %08x, should be %08x\n",
rc, MMSYSERR_NOERROR);
free(pwfx);
/* try invalid handle */