]> git.sur5r.net Git - i3/i3/commitdiff
Bugfix: Don’t free xinerama-reply if it is NULL, implement FREE()-macro (Thanks Igor)
authorMichael Stapelberg <michael+git@stapelberg.de>
Mon, 30 Mar 2009 06:27:53 +0000 (08:27 +0200)
committerMichael Stapelberg <michael+git@stapelberg.de>
Mon, 30 Mar 2009 06:27:53 +0000 (08:27 +0200)
include/util.h
src/xinerama.c

index a156f0a38944d358648725e3675a8b6941bc268d..4100089bdb6e78c09fe63efd6608497a28631fe3 100644 (file)
 #define FOR_TABLE(workspace) \
                         for (int cols = 0; cols < workspace->cols; cols++) \
                                 for (int rows = 0; rows < workspace->rows; rows++)
+#define FREE(pointer) do { \
+        if (pointer == NULL) { \
+                free(pointer); \
+                pointer = NULL; \
+        } \
+} \
+while (0)
 
 /* ##__VA_ARGS__ means: leave out __VA_ARGS__ completely if it is empty, that is,
    delete the preceding comma */
index 8d00eb4cddff02205d7f8a9fee4c6161d5e9fc24..ac820bd8d14bb999b365e2ba8964257918f0bdf2 100644 (file)
@@ -206,14 +206,14 @@ void initialize_xinerama(xcb_connection_t *conn) {
         xcb_xinerama_is_active_reply_t *reply;
         reply = xcb_xinerama_is_active_reply(conn, xcb_xinerama_is_active(conn), NULL);
 
-        if (!reply->state) {
+        if (reply == NULL || !reply->state) {
                 LOG("Xinerama is not active (in your X-Server), disabling.\n");
-                free(reply);
+                FREE(reply);
                 disable_xinerama(conn);
                 return;
         }
 
-        free(reply);
+        FREE(reply);
 
         query_screens(conn, virtual_screens);