[PATCH 4/4] winmm: Copy result buffer from MMIO_Open() to source buffer in mmioOpenW().

Andrew Eikum aeikum at codeweavers.com
Tue Jan 19 11:58:02 CST 2021


On Mon, Jan 18, 2021 at 09:45:34PM +0100, Gijs Vermeulen wrote:
> diff --git a/dlls/winmm/mmio.c b/dlls/winmm/mmio.c
> index 7882dc1c2f9..db210a29bec 100644
> --- a/dlls/winmm/mmio.c
> +++ b/dlls/winmm/mmio.c
> @@ -755,6 +755,13 @@ HMMIO WINAPI mmioOpenW(LPWSTR szFileName, MMIOINFO* lpmmioinfo,
>  
>      ret = MMIO_Open(szFn, lpmmioinfo, dwOpenFlags, TRUE);
>  
> +    if (szFileName)
> +    {
> +        INT len = MultiByteToWideChar( CP_ACP, 0, szFn, -1, NULL, 0 );
> +        if (len < 128) len = 128;
> +        MultiByteToWideChar( CP_ACP, 0, szFn, -1, szFileName, len );
> +    }
> +
>      HeapFree(GetProcessHeap(), 0, szFn);
>      return ret;
>  }

Are you sure we want to write to szFileName in all cases? Does Windows
do that? It seems possible an application would pass in something
const or write protected, which we won't want to touch.

Also I think you can just pass 128 in all cases, there's no reason to
get the destination length.

Andrew



More information about the wine-devel mailing list