]> git.sur5r.net Git - i3/i3lock/commitdiff
Properly free X11 resources (fixes DoS bug) (Thanks Merovius)
authorMichael Stapelberg <michael@stapelberg.de>
Wed, 28 Dec 2011 22:05:02 +0000 (23:05 +0100)
committerMichael Stapelberg <michael@stapelberg.de>
Wed, 28 Dec 2011 22:05:02 +0000 (23:05 +0100)
i3lock.c
xcb.c

index af93a1e1718160ddfe3bae98b73dfe02a828f3e8..64a7869ecc503836cd6862a358e90f3cc155939a 100644 (file)
--- a/i3lock.c
+++ b/i3lock.c
@@ -269,6 +269,7 @@ static void redraw_screen() {
     /* XXX: Possible optimization: Only update the area in the middle of the
      * screen instead of the whole screen. */
     xcb_clear_area(conn, 0, win, 0, 0, scr->width_in_pixels, scr->height_in_pixels);
+    xcb_free_pixmap(conn, bg_pixmap);
     xcb_flush(conn);
 }
 
@@ -571,6 +572,7 @@ void handle_screen_resize(xcb_visualtype_t *vistype, xcb_window_t win, uint32_t*
     if (img) {
         xcb_pixmap_t bg_pixmap = draw_image(vistype, last_resolution);
         xcb_change_window_attributes(conn, win, XCB_CW_BACK_PIXMAP, (uint32_t[1]){ bg_pixmap });
+        xcb_free_pixmap(conn, bg_pixmap);
     }
 #endif
 
@@ -830,6 +832,7 @@ int main(int argc, char *argv[]) {
 
     /* open the fullscreen window, already with the correct pixmap in place */
     win = open_fullscreen_window(conn, scr, color, bg_pixmap);
+    xcb_free_pixmap(conn, bg_pixmap);
 
     cursor = create_cursor(conn, scr, win, curs_choice);
 
diff --git a/xcb.c b/xcb.c
index c418bd5959a75b71659d12e527fb2a40957f9a84..0e04164c22c75c0c8c2fd4c66f5eedddc64e3317 100644 (file)
--- a/xcb.c
+++ b/xcb.c
@@ -90,6 +90,7 @@ xcb_pixmap_t create_bg_pixmap(xcb_connection_t *conn, xcb_screen_t *scr, u_int32
     xcb_create_gc(conn, gc, bg_pixmap, XCB_GC_FOREGROUND, values);
     xcb_rectangle_t rect = { 0, 0, resolution[0], resolution[1] };
     xcb_poly_fill_rectangle(conn, bg_pixmap, gc, 1, &rect);
+    xcb_free_gc(conn, gc);
 
     return bg_pixmap;
 }