From 7b2d347031440046cf5a03e9cab01a40d8111c42 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Wed, 10 Jul 2013 22:13:19 -0700 Subject: [PATCH] Catch out of memory errors creating a window --- src/video/SDL_video.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 801fa5e3e..1a3fbda8b 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -1212,6 +1212,10 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags) } } window = (SDL_Window *)SDL_calloc(1, sizeof(*window)); + if (!window) { + SDL_OutOfMemory(); + return NULL; + } window->magic = &_this->window_magic; window->id = _this->next_object_id++; window->x = x; @@ -1267,6 +1271,10 @@ SDL_CreateWindowFrom(const void *data) return NULL; } window = (SDL_Window *)SDL_calloc(1, sizeof(*window)); + if (!window) { + SDL_OutOfMemory(); + return NULL; + } window->magic = &_this->window_magic; window->id = _this->next_object_id++; window->flags = SDL_WINDOW_FOREIGN;