Do error checking in SDL_GetDisplayForWindow()
authorSam Lantinga <slouken@libsdl.org>
Mon, 21 Feb 2011 15:08:36 -0800
changeset 537302007fd16991
parent 5372 a244ea780baa
child 5374 dacb4f5e0dd3
Do error checking in SDL_GetDisplayForWindow()
src/video/SDL_video.c
     1.1 --- a/src/video/SDL_video.c	Mon Feb 21 11:04:27 2011 -0800
     1.2 +++ b/src/video/SDL_video.c	Mon Feb 21 15:08:36 2011 -0800
     1.3 @@ -888,7 +888,7 @@
     1.4  }
     1.5  
     1.6  int
     1.7 -SDLCALL SDL_GetWindowDisplay(SDL_Window * window)
     1.8 +SDL_GetWindowDisplay(SDL_Window * window)
     1.9  {
    1.10      int displayIndex;
    1.11      int i, dist;
    1.12 @@ -945,7 +945,12 @@
    1.13  SDL_VideoDisplay *
    1.14  SDL_GetDisplayForWindow(SDL_Window *window)
    1.15  {
    1.16 -    return &_this->displays[SDL_GetWindowDisplay(window)];
    1.17 +    int displayIndex = SDL_GetWindowDisplay(window);
    1.18 +    if (displayIndex >= 0) {
    1.19 +        return &_this->displays[displayIndex];
    1.20 +    } else {
    1.21 +        return NULL;
    1.22 +    }
    1.23  }
    1.24  
    1.25  int