Don't crash when no WM is present.
authorSam Lantinga <slouken@libsdl.org>
Wed, 27 Nov 2013 10:29:27 -0800
changeset 8034 b80feead1d04
parent 8033 8181c3a4a055
child 8035 2cc220c7e899
Don't crash when no WM is present. CR: Sam Lantinga.
android-project/src/org/libsdl/app/SDLActivity.java
premake/Linux/SDL_config_premake.h
premake/MinGW/SDL_config_premake.h
premake/VisualC/VS2008/SDL_config_premake.h
premake/VisualC/VS2010/SDL_config_premake.h
premake/VisualC/VS2012/SDL_config_premake.h
premake/Xcode-iOS/SDL_config_premake.h
premake/Xcode/Xcode3/SDL_config_premake.h
premake/Xcode/Xcode4/SDL_config_premake.h
premake/config/SDL_config_cygwin.template.h
premake/config/SDL_config_iphoneos.template.h
premake/config/SDL_config_linux.template.h
premake/config/SDL_config_macosx.template.h
premake/config/SDL_config_minimal.template.h
premake/config/SDL_config_windows.template.h
src/video/SDL_video.c
src/video/windows/SDL_windowsevents.c
src/video/windows/SDL_windowswindow.c
src/video/windows/SDL_windowswindow.h
src/video/x11/SDL_x11video.c
visualtest/config.h
visualtest/docs/html/bc_s.png
visualtest/docs/html/bdwn.png
visualtest/docs/html/closed.png
visualtest/docs/html/doxygen.png
visualtest/docs/html/ftv2blank.png
visualtest/docs/html/ftv2cl.png
visualtest/docs/html/ftv2doc.png
visualtest/docs/html/ftv2folderclosed.png
visualtest/docs/html/ftv2folderopen.png
visualtest/docs/html/ftv2lastnode.png
visualtest/docs/html/ftv2link.png
visualtest/docs/html/ftv2mlastnode.png
visualtest/docs/html/ftv2mnode.png
visualtest/docs/html/ftv2mo.png
visualtest/docs/html/ftv2node.png
visualtest/docs/html/ftv2ns.png
visualtest/docs/html/ftv2plastnode.png
visualtest/docs/html/ftv2pnode.png
visualtest/docs/html/ftv2splitbar.png
visualtest/docs/html/ftv2vertline.png
visualtest/docs/html/nav_f.png
visualtest/docs/html/nav_g.png
visualtest/docs/html/nav_h.png
visualtest/docs/html/open.png
visualtest/docs/html/search/close.png
visualtest/docs/html/search/mag_sel.png
visualtest/docs/html/search/search_l.png
visualtest/docs/html/search/search_m.png
visualtest/docs/html/search/search_r.png
visualtest/docs/html/sync_off.png
visualtest/docs/html/sync_on.png
visualtest/docs/html/tab_a.png
visualtest/docs/html/tab_b.png
visualtest/docs/html/tab_h.png
visualtest/docs/html/tab_s.png
visualtest/include/SDL_visualtest_action_configparser.h
visualtest/include/SDL_visualtest_exhaustive_variator.h
visualtest/include/SDL_visualtest_harness_argparser.h
visualtest/include/SDL_visualtest_mischelper.h
visualtest/include/SDL_visualtest_parsehelper.h
visualtest/include/SDL_visualtest_process.h
visualtest/include/SDL_visualtest_random_variator.h
visualtest/include/SDL_visualtest_rwhelper.h
visualtest/include/SDL_visualtest_screenshot.h
visualtest/include/SDL_visualtest_sut_configparser.h
visualtest/include/SDL_visualtest_variator_common.h
visualtest/include/SDL_visualtest_variators.h
visualtest/src/action_configparser.c
visualtest/src/harness_argparser.c
visualtest/src/linux/linux_process.c
visualtest/src/mischelper.c
visualtest/src/parsehelper.c
visualtest/src/rwhelper.c
visualtest/src/screenshot.c
visualtest/src/sut_configparser.c
visualtest/src/testharness.c
visualtest/src/variator_common.c
visualtest/src/variator_exhaustive.c
visualtest/src/variator_random.c
visualtest/src/variators.c
visualtest/src/windows/windows_process.c
visualtest/src/windows/windows_screenshot.c
visualtest/unittest/testquit.c
--- a/src/video/x11/SDL_x11video.c	Wed Nov 27 00:29:46 2013 -0800
+++ b/src/video/x11/SDL_x11video.c	Wed Nov 27 10:29:27 2013 -0800
@@ -440,8 +440,8 @@
     Atom _NET_SUPPORTING_WM_CHECK;
     int status, real_format;
     Atom real_type;
-    unsigned long items_read, items_left;
-    unsigned char *propdata;
+    unsigned long items_read = 0, items_left = 0;
+    unsigned char *propdata = NULL;
     Window wm_window = 0;
 #ifdef DEBUG_WINDOW_MANAGER
     char *wm_name;
@@ -453,11 +453,14 @@
 
     _NET_SUPPORTING_WM_CHECK = X11_XInternAtom(display, "_NET_SUPPORTING_WM_CHECK", False);
     status = X11_XGetWindowProperty(display, DefaultRootWindow(display), _NET_SUPPORTING_WM_CHECK, 0L, 1L, False, XA_WINDOW, &real_type, &real_format, &items_read, &items_left, &propdata);
-    if (status == Success && items_read) {
-        wm_window = ((Window*)propdata)[0];
-    }
-    if (propdata) {
-        X11_XFree(propdata);
+    if (status == Success) {
+        if (items_read) {
+            wm_window = ((Window*)propdata)[0];
+        }
+        if (propdata) {
+            X11_XFree(propdata);
+            propdata = NULL;
+        }
     }
 
     if (wm_window) {
@@ -465,8 +468,9 @@
         if (status != Success || !items_read || wm_window != ((Window*)propdata)[0]) {
             wm_window = None;
         }
-        if (propdata) {
+        if (status == Success && propdata) {
             X11_XFree(propdata);
+            propdata = NULL;
         }
     }