diff --git a/src/ClDisplay.c b/src/ClDisplay.c index aa904e51..31d3a841 100644 --- a/src/ClDisplay.c +++ b/src/ClDisplay.c @@ -47,6 +47,7 @@ XCloseDisplay ( { register _XExtension *ext; register int i; + xcb_connection_t *connection; if (!(dpy->flags & XlibDisplayClosing)) { @@ -68,7 +69,8 @@ XCloseDisplay ( if (X_DPY_GET_REQUEST(dpy) != X_DPY_GET_LAST_REQUEST_READ(dpy)) XSync(dpy, 1); } - xcb_disconnect(dpy->xcb->connection); + connection = dpy->xcb->connection; _XFreeDisplayStructure (dpy); + xcb_disconnect(connection); return 0; } diff --git a/src/OpenDis.c b/src/OpenDis.c index 89a0ebdf..6cc43ba3 100644 --- a/src/OpenDis.c +++ b/src/OpenDis.c @@ -709,7 +709,10 @@ void _XFreeDisplayStructure(Display *dpy) static void OutOfMemory(Display *dpy) { - if(dpy->xcb->connection) - xcb_disconnect(dpy->xcb->connection); + xcb_connection_t *connection = dpy->xcb->connection; + _XFreeDisplayStructure (dpy); + + if(connection) + xcb_disconnect(connection); }