Check the return value of xcb_get_window_attributes_reply() to prevent a crash if getting the window attributes would fail for some reason.
Also free the returned structure after usage to avoid memleaks.
This is necessary according to https://xcb.freedesktop.org/windowcontextandmanipulation (see the end of the page).