Skip to content
Permalink
Browse files

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.
  • Loading branch information
slouken committed Oct 3, 2009
1 parent 8df07e9 commit 0609684d87007736b4d6c177c6cdb71666f79298
Showing with 2 additions and 2 deletions.
  1. +1 −1 mixer.c
  2. +1 −1 music.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. */
}
@@ -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. */
}

0 comments on commit 0609684

Please sign in to comment.