Fix for buffer overflow in audio code, when feeding a device that needs SDL-1.2
authorRyan C. Gordon <icculus@icculus.org>
Fri, 27 Oct 2006 20:18:24 +0000
branchSDL-1.2
changeset 3884 dba874934f0c
parent 3883 cfe850b334e7
child 3885 a10bddfdc40f
Fix for buffer overflow in audio code, when feeding a device that needs resampling. Fixes Bugzilla #298.
src/audio/SDL_audio.c
--- a/src/audio/SDL_audio.c	Sat Oct 21 18:53:33 2006 +0000
+++ b/src/audio/SDL_audio.c	Fri Oct 27 20:18:24 2006 +0000
@@ -590,7 +590,8 @@
 			return(-1);
 		}
 		if ( audio->convert.needed ) {
-			audio->convert.len = desired->size;
+			audio->convert.len = (int) ( ((double) desired->size) /
+                                          audio->convert.len_ratio );
 			audio->convert.buf =(Uint8 *)SDL_AllocAudioMem(
 			   audio->convert.len*audio->convert.len_mult);
 			if ( audio->convert.buf == NULL ) {