We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 1914

Summary: sizeof(const char**) is suspicious in music.c file
Product: SDL_mixer Reporter: Nitz <nitin.j4>
Component: miscAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: 1.2.12   
Hardware: x86   
OS: Linux   

Description Nitz 2013-06-15 07:06:06 UTC
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 *));
Comment 1 Sam Lantinga 2013-06-18 03:45:08 UTC
Fixed, thanks!
http://hg.libsdl.org/SDL_mixer/rev/030181ff9f59