From 0609684d87007736b4d6c177c6cdb71666f79298 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 3 Oct 2009 08:46:55 +0000 Subject: [PATCH] Fixed bug #819 O.Sezer 2009-10-02 08:41:50 PDT SDL_mixer crashes in add_music_decoder() and add_chunk_decoder() due to a thinko in the size argument in the realloc() calls: the initial value of num_decoders is 0. Attached a quick fix. Regards. --- mixer.c | 2 +- music.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mixer.c b/mixer.c index a06450dc..b91379f8 100644 --- a/mixer.c +++ b/mixer.c @@ -117,7 +117,7 @@ const char *Mix_GetChunkDecoder(int index) static void add_chunk_decoder(const char *decoder) { - void *ptr = realloc(chunk_decoders, num_decoders * sizeof (const char **)); + void *ptr = realloc(chunk_decoders, (num_decoders + 1) * sizeof (const char **)); if (ptr == NULL) { return; /* oh well, go on without it. */ } diff --git a/music.c b/music.c index a785dc5b..18e87f4f 100644 --- a/music.c +++ b/music.c @@ -154,7 +154,7 @@ const char *Mix_GetMusicDecoder(int index) static void add_music_decoder(const char *decoder) { - void *ptr = realloc(music_decoders, num_decoders * sizeof (const char **)); + void *ptr = realloc(music_decoders, (num_decoders + 1) * sizeof (const char **)); if (ptr == NULL) { return; /* oh well, go on without it. */ }