Skip to content

Commit

Permalink
Fixed bug 2647 - Memory leak in SDL_AddHintCallback function - SDL_hi…
Browse files Browse the repository at this point in the history
…nts.c

Nitz

Variable entry going out of scope leaks the storage it points to, at:

        /* Need to add a hint entry for this watcher */
        hint = (SDL_Hint *)SDL_malloc(sizeof(*hint));
        if (!hint) {
            return;
        }

Patch is attached.
  • Loading branch information
philippwiesemann committed Oct 29, 2014
1 parent f2bd99d commit 2a46a9d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/SDL_hints.c
Expand Up @@ -149,6 +149,11 @@ SDL_AddHintCallback(const char *name, SDL_HintCallback callback, void *userdata)
/* Need to add a hint entry for this watcher */
hint = (SDL_Hint *)SDL_malloc(sizeof(*hint));
if (!hint) {
if(entry)
{
SDL_free(entry);
entry = NULL;
}
return;
}
hint->name = SDL_strdup(name);
Expand Down

0 comments on commit 2a46a9d

Please sign in to comment.