JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
plug some memory leaks.
authorDavid Hill <dhill@conformal.com>
Wed, 29 Aug 2012 15:35:40 +0000 (11:35 -0400)
committerDavid Hill <dhill@conformal.com>
Wed, 29 Aug 2012 15:35:40 +0000 (11:35 -0400)
spectrwm.c

index 75aec9c..ff3dfbd 100644 (file)
@@ -2802,6 +2802,7 @@ get_pointer_win(xcb_window_t root)
                } else {
                        DNPRINTF(SWM_D_EVENT, "get_pointer_win: none.\n");
                }
+               free(r);
        }
 
        return win;
@@ -4488,24 +4489,28 @@ get_win_name(xcb_window_t win)
            XCB_GET_PROPERTY_TYPE_ANY, 0, UINT_MAX);
        r = xcb_get_property_reply(conn, c, NULL);
 
-       if (!r || r->type == XCB_NONE) {
-               free(r);
-               /* Use WM_NAME instead; no UTF-8. */
-               c = xcb_get_property(conn, 0, win, XCB_ATOM_WM_NAME,
-                   XCB_GET_PROPERTY_TYPE_ANY, 0, UINT_MAX);
-               r = xcb_get_property_reply(conn, c, NULL);
-
-               if(!r || r->type == XCB_NONE) {
+       if (r) {
+               if (r->type == XCB_NONE) {
                        free(r);
-                       return NULL;
+                       /* Use WM_NAME instead; no UTF-8. */
+                       c = xcb_get_property(conn, 0, win, XCB_ATOM_WM_NAME,
+                               XCB_GET_PROPERTY_TYPE_ANY, 0, UINT_MAX);
+                       r = xcb_get_property_reply(conn, c, NULL);
+
+                       if (!r)
+                               return (NULL);
+                       if (r->type == XCB_NONE) {
+                               free(r);
+                               return (NULL);
+                       }
                }
-       }
+               if (r->length > 0)
+                       name = strndup(xcb_get_property_value(r),
+                                  xcb_get_property_value_length(r));
 
-       if (r->length > 0)
-               name = strndup(xcb_get_property_value(r),
-                   xcb_get_property_value_length(r));
+               free(r);
+       }
 
-       free(r);
        return (name);
 }