Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Catch out of memory errors creating a window
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Jul 11, 2013
1 parent 614f8e6 commit 7b2d347
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/video/SDL_video.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 7b2d347

Please sign in to comment.