WINMM: prevent division by zero in mciwave

Eric Pouech eric.pouech at wanadoo.fr
Tue Feb 14 01:41:59 CST 2006


Alex Villací­s Lasso wrote:
> This was found while digging for the source of the mp3 jittering 
> problem. Both native L3CODECA.ACM and winemp3 trigger this 
> division-by-zero exception with ACMAPP.EXE demonstration program from 
> MSDN when using the Player! menu item with a MP3-encoded .WAV file 
> unless this patch is applied.
> 
> Changelog:
> 
> * Prevent division-by-zero exception on codecs that do not report 
> bits-per-sample.
> 
> Alex Villacís Lasso
> 
> 
> ------------------------------------------------------------------------
> 
> diff -ur wine-0.9.7-cvs/dlls/winmm/mciwave/mciwave.c wine-0.9.7-cvs-patch/dlls/winmm/mciwave/mciwave.c
> --- wine-0.9.7-cvs/dlls/winmm/mciwave/mciwave.c	2005-12-06 16:28:17.000000000 -0500
> +++ wine-0.9.7-cvs-patch/dlls/winmm/mciwave/mciwave.c	2006-02-12 11:52:25.000000000 -0500
> @@ -205,7 +205,7 @@
>  	ret = val;
>  	break;
>      case MCI_FORMAT_SAMPLES: /* FIXME: is this correct ? */
> -	ret = (val * 8) / wmw->lpWaveFormat->wBitsPerSample;
> +	ret = (val * 8) / (wmw->lpWaveFormat->wBitsPerSample ? wmw->lpWaveFormat->wBitsPerSample : 1);
>  	break;
I think the overall fix is wrong. The computation is correct for PCM 
files, not for MP3 (and any other non linear compression format).
You should check how native mciavi32 behaves here.
A+
-- 
Eric Pouech




More information about the wine-devel mailing list