| Summary: | sizeof(const char**) is suspicious in music.c file | ||
|---|---|---|---|
| Product: | SDL_mixer | Reporter: | Nitz <nitin.j4> |
| Component: | misc | Assignee: | Ryan C. Gordon <icculus> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | ||
| Version: | 1.2.12 | ||
| Hardware: | x86 | ||
| OS: | Linux | ||
Fixed, thanks! http://hg.libsdl.org/SDL_mixer/rev/030181ff9f59 |
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 *));