Do error checking in SDL_GetDisplayForWindow()

This commit is contained in:
Sam Lantinga 2011-02-21 15:08:36 -08:00
parent 5d5c23d421
commit 9619f0bccf

View file

@ -888,7 +888,7 @@ SDL_SetDisplayModeForDisplay(SDL_VideoDisplay * display, const SDL_DisplayMode *
}
int
SDLCALL SDL_GetWindowDisplay(SDL_Window * window)
SDL_GetWindowDisplay(SDL_Window * window)
{
int displayIndex;
int i, dist;
@ -945,7 +945,12 @@ SDLCALL SDL_GetWindowDisplay(SDL_Window * window)
SDL_VideoDisplay *
SDL_GetDisplayForWindow(SDL_Window *window)
{
return &_this->displays[SDL_GetWindowDisplay(window)];
int displayIndex = SDL_GetWindowDisplay(window);
if (displayIndex >= 0) {
return &_this->displays[displayIndex];
} else {
return NULL;
}
}
int