Do error checking in SDL_GetDisplayForWindow()
authorSam Lantinga <slouken@libsdl.org>
Mon, 21 Feb 2011 15:08:36 -0800
changeset 5373 02007fd16991
parent 5372 a244ea780baa
child 5374 dacb4f5e0dd3
Do error checking in SDL_GetDisplayForWindow()
src/video/SDL_video.c
--- a/src/video/SDL_video.c	Mon Feb 21 11:04:27 2011 -0800
+++ b/src/video/SDL_video.c	Mon Feb 21 15:08:36 2011 -0800
@@ -888,7 +888,7 @@
 }
 
 int
-SDLCALL SDL_GetWindowDisplay(SDL_Window * window)
+SDL_GetWindowDisplay(SDL_Window * window)
 {
     int displayIndex;
     int i, dist;
@@ -945,7 +945,12 @@
 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