winmm: Initialize struct MMIOINFO in MMIO_Open (try 2)

Andrew Eikum aeikum at codeweavers.com
Mon Oct 26 07:55:25 CDT 2015


Signed-off-by: Andrew Eikum <aeikum at codeweavers.com>

On Sun, Oct 25, 2015 at 12:38:38PM +0800, Bruno Jesus wrote:
> Signed-off-by: Bruno Jesus <00cpxxx at gmail.com>
> 
> Superseeds 115694.
> 
> Try 2:
> Zero the whole struct as suggested by Andrew Eikum
> 
> The program from bug 35872 registers an IO handler that test adwInfo
> and crashes because when MMIO_Open is called these values have
> garbage.
> 
> Fixes https://bugs.winehq.org/show_bug.cgi?id=35872

> diff --git a/dlls/winmm/mmio.c b/dlls/winmm/mmio.c
> index ad73564..bc69f9e 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 fd5433c..48367ee 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));

> 




More information about the wine-patches mailing list