From 032b14e7b6667f6b6e1660c25c62dcb684b9cf93 Mon Sep 17 00:00:00 2001 From: Philipp Wiesemann Date: Wed, 29 Oct 2014 20:29:32 +0100 Subject: [PATCH] Fixed SDL_AddHintCallback() crashing if no more memory available. The return value of SDL_malloc() was not checked and NULL therefore not handled. Also added setting of error message for the other SDL_malloc() in this function. --- src/SDL_hints.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/SDL_hints.c b/src/SDL_hints.c index 34bd76863351f..520e4eaa950be 100644 --- a/src/SDL_hints.c +++ b/src/SDL_hints.c @@ -137,6 +137,10 @@ SDL_AddHintCallback(const char *name, SDL_HintCallback callback, void *userdata) SDL_DelHintCallback(name, callback, userdata); entry = (SDL_HintWatch *)SDL_malloc(sizeof(*entry)); + if (!entry) { + SDL_OutOfMemory(); + return; + } entry->callback = callback; entry->userdata = userdata; @@ -149,6 +153,7 @@ 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) { + SDL_OutOfMemory(); if(entry) { SDL_free(entry);