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.
This commit is contained in:
parent
0f7e05d107
commit
290396bf46
1 changed files with 5 additions and 0 deletions
|
@ -137,6 +137,10 @@ SDL_AddHintCallback(const char *name, SDL_HintCallback callback, void *userdata)
|
||||||
SDL_DelHintCallback(name, callback, userdata);
|
SDL_DelHintCallback(name, callback, userdata);
|
||||||
|
|
||||||
entry = (SDL_HintWatch *)SDL_malloc(sizeof(*entry));
|
entry = (SDL_HintWatch *)SDL_malloc(sizeof(*entry));
|
||||||
|
if (!entry) {
|
||||||
|
SDL_OutOfMemory();
|
||||||
|
return;
|
||||||
|
}
|
||||||
entry->callback = callback;
|
entry->callback = callback;
|
||||||
entry->userdata = userdata;
|
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 */
|
/* Need to add a hint entry for this watcher */
|
||||||
hint = (SDL_Hint *)SDL_malloc(sizeof(*hint));
|
hint = (SDL_Hint *)SDL_malloc(sizeof(*hint));
|
||||||
if (!hint) {
|
if (!hint) {
|
||||||
|
SDL_OutOfMemory();
|
||||||
if(entry)
|
if(entry)
|
||||||
{
|
{
|
||||||
SDL_free(entry);
|
SDL_free(entry);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue