msadpcm32.acm: Stop converting data instead of crashing

Andrew Eikum aeikum at codeweavers.com
Mon Sep 28 08:35:14 CDT 2015


On Sun, Sep 27, 2015 at 12:42:42AM +0800, Bruno Jesus wrote:
> Signed-off-by: Bruno Jesus <00cpxxx at gmail.com>
> 
> Tomb Raider 3 uses a single archive with all wav files inside, when
> playing some specific sounds it passes incorrect lengths of data that
> reach the next wav file header. This causes an assert in the code that
> is now gracefully handled.
> 
> Fixes bug https://bugs.winehq.org/show_bug.cgi?id=21000

> diff --git a/dlls/msadp32.acm/msadp32.c b/dlls/msadp32.acm/msadp32.c
> index 2c61575..0924163 100644
> --- a/dlls/msadp32.acm/msadp32.c
> +++ b/dlls/msadp32.acm/msadp32.c
> @@ -249,9 +249,17 @@ static	void cvtSSms16K(const ACMDRVSTREAMINSTANCE *adsi,
>      {
>          const unsigned char*    in_src = src;
>  
> -        assert(*src <= 6);
> +        /* Catch a problem from Tomb Raider III (bug 21000) where it passes
> +         * invalid data after a valid sequence of blocks */
> +        if (*src > 6 || *(src + 1) > 6)
> +        {
> +            /* Recalculate the amount of used output buffer. We are not changing
> +             * nsrc, let's assume the bad data was parsed */
> +            *ndst -= nblock * nsamp_blk * adsi->pwfxDst->nBlockAlign;
> +            ERR("Invalid ADPCM data, stopping conversion\n");

Looks reasonable, thanks. I think you should change that message to a
WARN. Audio methods are often called thousands of times per second, so
spamming an ERR can be very obnoxious.

Andrew



More information about the wine-devel mailing list