SDL-mirror/src
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
..
atomic Happy New Year! 2011-12-31 09:28:07 -05:00
audio Fixed bug 1014 - SDL_ConvertAudio crashes 2012-01-08 17:10:57 -05:00
core Made the application activity events consistent between iOS and Android 2012-01-08 13:42:03 -05:00
cpuinfo Happy New Year! 2011-12-31 09:28:07 -05:00
events Happy New Year! 2011-12-31 09:28:07 -05:00
file Happy New Year! 2011-12-31 09:28:07 -05:00
haptic Check return value, not unsigned "supported" flags 2011-12-31 13:28:07 -05:00
joystick Fixed bug 1337 - joystick crash due to heap corruption with btnx 2012-01-01 16:58:00 -05:00
libm Happy New Year! 2011-12-31 09:28:07 -05:00
loadso Happy New Year! 2011-12-31 09:28:07 -05:00
main Fixed bug 1293 - [Android] Support Pause/Resume 2012-01-08 01:05:25 -05:00
power Happy New Year! 2011-12-31 09:28:07 -05:00
render X11 OpenGL ES minor corrections 2012-01-08 13:31:22 -05:00
stdlib Happy New Year! 2011-12-31 09:28:07 -05:00
thread Happy New Year! 2011-12-31 09:28:07 -05:00
timer Happy New Year! 2011-12-31 09:28:07 -05:00
video Made the application activity events consistent between iOS and Android 2012-01-08 13:42:03 -05:00
SDL.c Happy New Year! 2011-12-31 09:28:07 -05:00
SDL_assert.c Happy New Year! 2011-12-31 09:28:07 -05:00
SDL_assert_c.h Happy New Year! 2011-12-31 09:28:07 -05:00
SDL_compat.c Happy New Year! 2011-12-31 09:28:07 -05:00
SDL_error.c Happy New Year! 2011-12-31 09:28:07 -05:00
SDL_error_c.h Happy New Year! 2011-12-31 09:28:07 -05:00
SDL_fatal.c Happy New Year! 2011-12-31 09:28:07 -05:00
SDL_fatal.h Happy New Year! 2011-12-31 09:28:07 -05:00
SDL_hints.c Happy New Year! 2011-12-31 09:28:07 -05:00
SDL_hints_c.h Happy New Year! 2011-12-31 09:28:07 -05:00
SDL_log.c Happy New Year! 2011-12-31 09:28:07 -05:00