From 54ecab2479119388c815c86efeb28526e3d18d21 Mon Sep 17 00:00:00 2001 From: Bruno Jesus <00cpxxx@gmail.com> Date: Sun, 25 Oct 2015 12:38:38 +0800 Subject: [PATCH] winmm: Initialize struct MMIOINFO in MMIO_Open. Signed-off-by: Bruno Jesus <00cpxxx@gmail.com> Signed-off-by: Andrew Eikum Signed-off-by: Alexandre Julliard --- dlls/winmm/mmio.c | 6 +----- dlls/winmm/tests/mmio.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/dlls/winmm/mmio.c b/dlls/winmm/mmio.c index ad735641b5..bc69f9ec1d 100644 --- a/dlls/winmm/mmio.c +++ b/dlls/winmm/mmio.c @@ -591,11 +591,7 @@ static HMMIO MMIO_Open(LPSTR szFileName, MMIOINFO* refmminfo, DWORD dwOpenFlags, if (!refmminfo) { refmminfo = &mmioinfo; - - mmioinfo.fccIOProc = 0; - mmioinfo.pIOProc = NULL; - mmioinfo.pchBuffer = NULL; - mmioinfo.cchBuffer = 0; + memset(&mmioinfo, 0, sizeof(mmioinfo)); is_unicode = FALSE; } diff --git a/dlls/winmm/tests/mmio.c b/dlls/winmm/tests/mmio.c index fd5433cdb1..48367ee6d9 100644 --- a/dlls/winmm/tests/mmio.c +++ b/dlls/winmm/tests/mmio.c @@ -599,12 +599,15 @@ static void test_mmioSetBuffer(char *fname) static LRESULT CALLBACK mmio_test_IOProc(LPSTR lpMMIOInfo, UINT uMessage, LPARAM lParam1, LPARAM lParam2) { LPMMIOINFO lpInfo = (LPMMIOINFO) lpMMIOInfo; + int i; switch (uMessage) { case MMIOM_OPEN: if (lpInfo->fccIOProc == FOURCC_DOS) lpInfo->fccIOProc = mmioFOURCC('F', 'A', 'I', 'L'); + for (i = 0; i < sizeof(lpInfo->adwInfo) / sizeof(*lpInfo->adwInfo); i++) + ok(lpInfo->adwInfo[i] == 0, "[%d] Expected 0, got %u\n", i, lpInfo->adwInfo[i]); return MMSYSERR_NOERROR; case MMIOM_CLOSE: return MMSYSERR_NOERROR; @@ -642,6 +645,18 @@ static void test_mmioOpen_fourcc(void) mmio.lDiskOffset); mmioClose(hmmio, 0); + /* Same test with NULL info */ + memset(&mmio, 0, sizeof(mmio)); + hmmio = mmioOpenA(fname, NULL, MMIO_READ); + mmioGetInfo(hmmio, &mmio, 0); + ok(hmmio && mmio.fccIOProc == FOURCC_XYZ, "mmioOpenA error %u, got %4.4s\n", + mmio.wErrorRet, (LPCSTR)&mmio.fccIOProc); + ok(mmio.adwInfo[1] == 0, "mmioOpenA sent MMIOM_SEEK, got %d\n", + mmio.adwInfo[1]); + ok(mmio.lDiskOffset == 0, "mmioOpenA updated lDiskOffset, got %d\n", + mmio.lDiskOffset); + mmioClose(hmmio, 0); + mmioInstallIOProcA(FOURCC_XYZ, NULL, MMIO_REMOVEPROC); memset(&mmio, 0, sizeof(mmio));