From 2a46a9df21c190dcf89cda54b274105735deafa6 Mon Sep 17 00:00:00 2001 From: Philipp Wiesemann Date: Wed, 29 Oct 2014 20:20:47 +0100 Subject: [PATCH] Fixed bug 2647 - Memory leak in SDL_AddHintCallback function - SDL_hints.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. --- src/SDL_hints.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/SDL_hints.c b/src/SDL_hints.c index 365459ec76eca..34bd76863351f 100644 --- a/src/SDL_hints.c +++ b/src/SDL_hints.c @@ -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);