commit bd954b9413a16314c24c17dc9a4aacce3fa4c529
Author: Eric Wasylishen <ewasylishen@gmail.com>
AuthorDate: Tue Oct 31 14:30:08 2017 -0600
Commit: Eric Wasylishen <ewasylishen@gmail.com>
CommitDate: Tue Oct 31 14:48:40 2017 -0600
Allocate large enough buffer for SDL_ConvertAudio.
Fixes #945
---
src/i_sdlsound.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/i_sdlsound.c b/src/i_sdlsound.c
index 32653099..4f256b88 100644
--- a/src/i_sdlsound.c
+++ b/src/i_sdlsound.c
@@ -631,11 +631,15 @@ static boolean ExpandSoundData_SDL(sfxinfo_t *sfxinfo,
AUDIO_U8, 1, samplerate,
mixer_format, mixer_channels, mixer_freq))
{
- convertor.buf = chunk->abuf;
convertor.len = length;
+ convertor.buf = malloc(convertor.len * convertor.len_mult);
+ assert(convertor.buf != NULL);
memcpy(convertor.buf, data, length);
SDL_ConvertAudio(&convertor);
+
+ memcpy(chunk->abuf, convertor.buf, chunk->alen);
+ free(convertor.buf);
}
else
{