Catch out of memory errors creating a window
authorSam Lantinga <slouken@libsdl.org>
Wed, 10 Jul 2013 22:13:19 -0700
changeset 7399f35ff854121a
parent 7398 31ec14665b79
child 7400 243dad4e5f29
Catch out of memory errors creating a window
src/video/SDL_video.c
     1.1 --- a/src/video/SDL_video.c	Wed Jul 10 22:06:11 2013 -0700
     1.2 +++ b/src/video/SDL_video.c	Wed Jul 10 22:13:19 2013 -0700
     1.3 @@ -1212,6 +1212,10 @@
     1.4          }
     1.5      }
     1.6      window = (SDL_Window *)SDL_calloc(1, sizeof(*window));
     1.7 +    if (!window) {
     1.8 +        SDL_OutOfMemory();
     1.9 +        return NULL;
    1.10 +    }
    1.11      window->magic = &_this->window_magic;
    1.12      window->id = _this->next_object_id++;
    1.13      window->x = x;
    1.14 @@ -1267,6 +1271,10 @@
    1.15          return NULL;
    1.16      }
    1.17      window = (SDL_Window *)SDL_calloc(1, sizeof(*window));
    1.18 +    if (!window) {
    1.19 +        SDL_OutOfMemory();
    1.20 +        return NULL;
    1.21 +    }
    1.22      window->magic = &_this->window_magic;
    1.23      window->id = _this->next_object_id++;
    1.24      window->flags = SDL_WINDOW_FOREIGN;