Allocate SDL_AudioCVT::coeff before using it.
authorRyan C. Gordon <icculus@icculus.org>
Fri, 19 Dec 2008 08:30:26 +0000
changeset 2880 3c2f56e433a8
parent 2879 3ff86c46d324
child 2881 c8d203ef4335
Allocate SDL_AudioCVT::coeff before using it. FIXME: this is a memory leak. We don't have an SDL_FreeAudioCVT() yet.
src/audio/SDL_audiocvt.c
--- a/src/audio/SDL_audiocvt.c	Fri Dec 19 06:43:41 2008 +0000
+++ b/src/audio/SDL_audiocvt.c	Fri Dec 19 08:30:26 2008 +0000
@@ -1682,6 +1682,12 @@
         } \
     }
 
+    /* !!! FIXME: this memory leaks. */
+    cvt->coeff = (Uint8 *) SDL_malloc((SDL_AUDIO_BITSIZE(format) / 8) * m);
+    if (cvt->coeff == NULL) {
+        return -1;
+    }
+
     /* If we're using floating point, we only need to normalize */
     if (SDL_AUDIO_ISFLOAT(format) && SDL_AUDIO_BITSIZE(format) == 32) {
         float *fDest = (float *) cvt->coeff;