Fix regression causing crashes when running without a window manager.
authorPierre-Loup A. Griffais <pgriffais@valvesoftware.com>
Wed, 23 Oct 2013 13:43:17 -0700
changeset 7885 a8bd63b33636
parent 7884 15027aa2cf21
child 7886 ce301a5cc814
Fix regression causing crashes when running without a window manager.
src/video/x11/SDL_x11events.c
--- a/src/video/x11/SDL_x11events.c	Wed Oct 23 15:54:12 2013 -0400
+++ b/src/video/x11/SDL_x11events.c	Wed Oct 23 13:43:17 2013 -0700
@@ -525,19 +525,22 @@
             long border_bottom = 0;
             if (data->xwindow) {
                 Atom _net_frame_extents = X11_XInternAtom(display, "_NET_FRAME_EXTENTS", 0);
-                Atom type;
+                Atom type = None;
                 int format;
-                unsigned long nitems, bytes_after;
+                unsigned long nitems = 0, bytes_after;
                 unsigned char *property;
                 X11_XGetWindowProperty(display, data->xwindow,
                     _net_frame_extents, 0, 16, 0,
                     XA_CARDINAL, &type, &format,
                     &nitems, &bytes_after, &property);
 
-                border_left = ((long*)property)[0];
-                border_right = ((long*)property)[1];
-                border_top = ((long*)property)[2];
-                border_bottom = ((long*)property)[3];
+                if (type != None && nitems == 4)
+                {
+                    border_left = ((long*)property)[0];
+                    border_right = ((long*)property)[1];
+                    border_top = ((long*)property)[2];
+                    border_bottom = ((long*)property)[3];
+                }
             }
 
             if (xevent.xconfigure.x != data->last_xconfigure.x ||