decoders/smpeg.c patch (fixes smpeg error-reporting crash)

interim.descriptor at interim.descriptor at
Sat Sep 16 07:12:57 EDT 2006

decoders/smpeg.c contains the following fun snippet of code on line 174:

    if (SMPEG_error(smpeg))
            BAIL_MACRO(SMPEG_error(smpeg), 0);
    } /* if */

Notice how first the smpeg pointer is deleted, and THEN we call 
BAIL_MACRO() using the deleted smpeg pointer as an argument. This can 
make SDL_sound crash when decoding a bad mp3.

My tested solution was to replace the above code with this:

    char *errMsg=SMPEG_error(smpeg);
    if (errMsg)
            BAIL_MACRO(errMsg, 0);
    } /* if */

SDL_Sound now fails gracefully when decoding bad mp3s, instead of crashing.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the sdlsound mailing list