XCB/window: fix potential use-after-free