Catch out of memory errors creating a window

This commit is contained in:
Sam Lantinga 2013-07-10 22:13:19 -07:00
parent 08738a32fb
commit 8d546288b9

View file

@ -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;