Skip to content

Commit

Permalink
Fixed bug #819
Browse files Browse the repository at this point in the history
 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 0609684
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion mixer.c
Expand Up @@ -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. */
}
Expand Down
2 changes: 1 addition & 1 deletion music.c
Expand Up @@ -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. */
}
Expand Down

0 comments on commit 0609684

Please sign in to comment.