From b436db8647dc72249bda2be3c7d99d1dec78b0f1 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Tue, 18 Jun 2013 00:44:41 -0700 Subject: [PATCH] Fixed bugs 1914, 1915 - sizeof(const char**) is suspicious Nitz In function: static void add_music_decoder(const char *decoder) { void *ptr = SDL_realloc(music_decoders, (num_decoders + 1) * sizeof (const char **)); if (ptr == NULL) { return; /* oh well, go on without it. */ } music_decoders = (const char **) ptr; music_decoders[num_decoders++] = decoder; } Passing argument sizeof(char const **) to function SDL_realloc is suspicious. Logically it should be sizeof(char const *) instead of sizeof (char const **) In this particular case sizeof(char const **) happens to be equal to sizeof(char const *), but this is not a portable assumption. It reduces the understanding of the user. So Patch should be, void *ptr=SDL_realloc(music_decoders,(num_decoders+1) * sizeof(const char *)); --- mixer.c | 2 +- music.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mixer.c b/mixer.c index 559e60bc..d8ccbbf3 100644 --- a/mixer.c +++ b/mixer.c @@ -127,7 +127,7 @@ const char *Mix_GetChunkDecoder(int index) static void add_chunk_decoder(const char *decoder) { - void *ptr = SDL_realloc((void *)chunk_decoders, (num_decoders + 1) * sizeof (const char **)); + void *ptr = SDL_realloc((void *)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 d268fba8..4f14d5b6 100644 --- a/music.c +++ b/music.c @@ -163,7 +163,7 @@ const char *Mix_GetMusicDecoder(int index) static void add_music_decoder(const char *decoder) { - void *ptr = SDL_realloc((void *)music_decoders, (num_decoders + 1) * sizeof (const char **)); + void *ptr = SDL_realloc((void *)music_decoders, (num_decoders + 1) * sizeof (const char *)); if (ptr == NULL) { return; /* oh well, go on without it. */ }