more msacm fixes with tests
Robert Reif
reif at earthlink.net
Fri May 7 19:34:24 CDT 2004
More parameter checking fixes with tests.
-------------- next part --------------
Index: dlls/msacm/format.c
===================================================================
RCS file: /home/wine/wine/dlls/msacm/format.c,v
retrieving revision 1.25
diff -u -r1.25 format.c
--- dlls/msacm/format.c 3 May 2004 20:09:42 -0000 1.25
+++ dlls/msacm/format.c 7 May 2004 23:20:53 -0000
@@ -741,6 +741,15 @@
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 @@
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
Index: dlls/msacm/pcmconverter.c
===================================================================
RCS file: /home/wine/wine/dlls/msacm/pcmconverter.c,v
retrieving revision 1.18
diff -u -r1.18 pcmconverter.c
--- dlls/msacm/pcmconverter.c 12 Mar 2004 20:24:50 -0000 1.18
+++ dlls/msacm/pcmconverter.c 7 May 2004 23:20:54 -0000
@@ -960,7 +960,7 @@
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 */
Index: dlls/msacm/tests/msacm.c
===================================================================
RCS file: /home/wine/wine/dlls/msacm/tests/msacm.c,v
retrieving revision 1.1
diff -u -r1.1 msacm.c
--- dlls/msacm/tests/msacm.c 3 May 2004 20:17:43 -0000 1.1
+++ dlls/msacm/tests/msacm.c 7 May 2004 23:20:55 -0000
@@ -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 @@
if (rc == MMSYSERR_NOERROR) {
DWORD dwSize;
- WAVEFORMATEX * pwfx;
- ACMFORMATDETAILS fd;
HACMDRIVERID hid;
/* try bad pointer */
@@ -202,6 +210,10 @@
"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 @@
"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 */
More information about the wine-patches
mailing list