SDL-mirror/src/audio
Sam Lantinga a9bcdb83a9 Fixed bug 1014 - SDL_ConvertAudio crashes
The patch Mark attached looks good and valgrind gives it a clean bill of health:

Mark.Howson@ntu.ac.uk 2010-12-15 07:45:25 PST

Reproducible here under Windows and Linux. Looking at the code for
SDL_Upsample_S16LSB_2c:

const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 2;
const Sint16 *target = ((const Sint16 *) cvt->buf) - 2;
while (dst > target) {
   dst[1] = ((Sint16) SDL_SwapLE16(sample1));
   dst[0] = ((Sint16) SDL_SwapLE16(sample0));
   dst -= 2;
...

if dstsize is odd (and therefore dst), it'll write to target[1] which is one
byte before the allocated buf.

The attached patch to sdlgenaudiocvt.pl changes dst > target to dst >= target,
and removes the - $channels for the upsample case. The patch is not fully
tested, but seems to work here.
2012-01-08 17:10:57 -05:00
..
alsa Happy New Year! 2011-12-31 09:28:07 -05:00
android Happy New Year! 2011-12-31 09:28:07 -05:00
arts Use arts_suspend() in a loop to wait for arts to become ready. 2012-01-02 15:16:45 -05:00
baudio Happy New Year! 2011-12-31 09:28:07 -05:00
bsd Happy New Year! 2011-12-31 09:28:07 -05:00
coreaudio Happy New Year! 2011-12-31 09:28:07 -05:00
directsound Happy New Year! 2011-12-31 09:28:07 -05:00
disk Happy New Year! 2011-12-31 09:28:07 -05:00
dsp Happy New Year! 2011-12-31 09:28:07 -05:00
dummy Happy New Year! 2011-12-31 09:28:07 -05:00
esd Happy New Year! 2011-12-31 09:28:07 -05:00
fusionsound Happy New Year! 2011-12-31 09:28:07 -05:00
nas Happy New Year! 2011-12-31 09:28:07 -05:00
nds Happy New Year! 2011-12-31 09:28:07 -05:00
paudio Happy New Year! 2011-12-31 09:28:07 -05:00
pulseaudio Happy New Year! 2011-12-31 09:28:07 -05:00
qsa Happy New Year! 2011-12-31 09:28:07 -05:00
sun Happy New Year! 2011-12-31 09:28:07 -05:00
winmm Happy New Year! 2011-12-31 09:28:07 -05:00
xaudio2 Fixed bug 1362 - SDL Fails to compile with Visual C++ Express 2008 with Feb 2007 DirectX SDK 2012-01-07 00:57:24 -05:00
SDL_audio.c Happy New Year! 2011-12-31 09:28:07 -05:00
SDL_audio_c.h Happy New Year! 2011-12-31 09:28:07 -05:00
SDL_audiocvt.c Happy New Year! 2011-12-31 09:28:07 -05:00
SDL_audiodev.c Happy New Year! 2011-12-31 09:28:07 -05:00
SDL_audiodev_c.h Happy New Year! 2011-12-31 09:28:07 -05:00
SDL_audiomem.h Happy New Year! 2011-12-31 09:28:07 -05:00
SDL_audiotypecvt.c Fixed bug 1014 - SDL_ConvertAudio crashes 2012-01-08 17:10:57 -05:00
SDL_mixer.c Happy New Year! 2011-12-31 09:28:07 -05:00
SDL_sysaudio.h Happy New Year! 2011-12-31 09:28:07 -05:00
SDL_wave.c Happy New Year! 2011-12-31 09:28:07 -05:00
SDL_wave.h Happy New Year! 2011-12-31 09:28:07 -05:00
sdlgenaudiocvt.pl Fixed bug 1014 - SDL_ConvertAudio crashes 2012-01-08 17:10:57 -05:00