Index: xorg-server-7.2.0.0-1.5.99.1/hw/dmx/dmxcmap.c
===================================================================
--- xorg-server-7.2.0.0-1.5.99.1.orig/hw/dmx/dmxcmap.c
+++ xorg-server-7.2.0.0-1.5.99.1/hw/dmx/dmxcmap.c
@@ -97,10 +97,8 @@ Bool dmxCreateColormap(ColormapPtr pColo
     if (!dmxAllocateColormapPrivates(pColormap))
 	return FALSE;
 
-    if (dmxScreen->beDisplay) {
-	if (!dmxBECreateColormap(pColormap))
-	    return FALSE;
-    }
+    if (dmxScreen->beDisplay)
+	dmxBECreateColormap(pColormap);
 
     DMX_UNWRAP(CreateColormap, dmxScreen, pScreen);
     if (pScreen->CreateColormap)
Index: xorg-server-7.2.0.0-1.5.99.1/hw/dmx/dmxgcops.c
===================================================================
--- xorg-server-7.2.0.0-1.5.99.1.orig/hw/dmx/dmxgcops.c
+++ xorg-server-7.2.0.0-1.5.99.1/hw/dmx/dmxgcops.c
@@ -646,6 +646,7 @@ void dmxGetImage(DrawablePtr pDrawable,
     while (i < dmxNumScreens)
     {
 	xcb_get_image_reply_t *reply;
+	const xcb_setup_t     *setup;
 
 	if (!draw)
 	{
@@ -664,11 +665,12 @@ void dmxGetImage(DrawablePtr pDrawable,
 						    sx, sy, w, h,
 						    planeMask),
 				     NULL);
-	if (reply)
+
+	setup = xcb_get_setup (dmxScreen->connection);
+	if (reply && setup)
 	{
-	    const xcb_setup_t *setup = xcb_get_setup (dmxScreen->connection);
-	    uint32_t          bytes = xcb_get_image_data_length (reply);
-	    uint8_t           *data = xcb_get_image_data (reply);
+	    uint32_t bytes = xcb_get_image_data_length (reply);
+	    uint8_t  *data = xcb_get_image_data (reply);
 
 	    /* based on code in xcb_image.c, Copyright (C) 2007 Bart Massey */
 	    switch (format) {
@@ -714,6 +716,10 @@ void dmxGetImage(DrawablePtr pDrawable,
 	    free (reply);
 	    break;
 	}
+	else if (reply)
+	{
+	    free (reply);
+	}
 
 	if (pDrawable->type != DRAWABLE_WINDOW)
 	    break;
Index: xorg-server-7.2.0.0-1.5.99.1/hw/dmx/dmxinput.c
===================================================================
--- xorg-server-7.2.0.0-1.5.99.1.orig/hw/dmx/dmxinput.c
+++ xorg-server-7.2.0.0-1.5.99.1/hw/dmx/dmxinput.c
@@ -85,6 +85,9 @@ dmxUpdateKeycodeMap (DeviceIntPtr pDevic
     int               width = src->mapWidth;
     int               i;
 
+    if (!setup)
+	return;
+
     if (!pDevice->isMaster && pDevice->u.master)
     {
 	if (IsKeyboardDevice (pDevice->u.master))
@@ -282,6 +285,9 @@ dmxKeyEvent (DeviceIntPtr pDevice,
     const xcb_setup_t *setup = xcb_get_setup (dmxScreen->connection);
     int               nEvents = 0;
 
+    if (!setup)
+	return 0;
+
     if (key >= setup->min_keycode && key <= setup->max_keycode)
     {
 	int keycode = pDevPriv->keycode[key - setup->min_keycode];
@@ -1743,7 +1749,12 @@ dmxKeyboardOn (DeviceIntPtr pDevice)
     dmxDevicePrivPtr  pDevPriv = DMX_GET_DEVICE_PRIV (pDevice);
     DMXScreenInfo     *dmxScreen = (DMXScreenInfo *) pDevPriv->dmxInput;
     const xcb_setup_t *setup = xcb_get_setup (dmxScreen->connection);
-    int               nKeycode = setup->max_keycode - setup->min_keycode;
+    int               nKeycode;
+
+    if (!setup)
+	return -1;
+
+    nKeycode = setup->max_keycode - setup->min_keycode;
 
     pDevPriv->keycode = xalloc (nKeycode * sizeof (KeyCode));
     if (!pDevPriv->keycode)
@@ -2424,33 +2435,37 @@ dmxChangeKeyboardMapping (DeviceIntPtr p
 
     for (i = 0; i < dmxNumScreens; i++)
     {
-	DMXScreenInfo *dmxScreen = &dmxScreens[i];
+	DMXScreenInfo     *dmxScreen = &dmxScreens[i];
+	DMXInputInfo      *dmxInput = &dmxScreen->input;
+	const xcb_setup_t *setup;
+	int               nKeycode;
 
-	if (dmxScreen->beDisplay)
-	{
-	    DMXInputInfo      *dmxInput = &dmxScreen->input;
-	    const xcb_setup_t *setup = xcb_get_setup (dmxScreen->connection);
-	    int               nKeycode = setup->max_keycode -
-		setup->min_keycode;
+	if (!dmxScreen->beDisplay)
+	    continue;
 
-	    for (j = 0; j < dmxInput->numDevs; j++)
-	    {
-                if (!IsKeyboardDevice (dmxInput->devs[j]))
-                    continue;
+	setup = xcb_get_setup (dmxScreen->connection);
+	if (!setup)
+	    continue;
 
-		if (pDevice && dmxInput->devs[j] != pDevice)
-		{
-		    if (dmxInput->devs[j]->isMaster)
-			continue;
+	nKeycode = setup->max_keycode - setup->min_keycode;
 
-		    if (dmxInput->devs[j]->u.master != pDevice)
-			continue;
-		}
+	for (j = 0; j < dmxInput->numDevs; j++)
+	{
+	    if (!IsKeyboardDevice (dmxInput->devs[j]))
+		continue;
+
+	    if (pDevice && dmxInput->devs[j] != pDevice)
+	    {
+		if (dmxInput->devs[j]->isMaster)
+		    continue;
 
-		dmxUpdateKeyboardMapping (dmxInput->devs[j],
-					  setup->min_keycode,
-					  nKeycode);
+		if (dmxInput->devs[j]->u.master != pDevice)
+		    continue;
 	    }
+
+	    dmxUpdateKeyboardMapping (dmxInput->devs[j],
+				      setup->min_keycode,
+				      nKeycode);
 	}
     }
 }
Index: xorg-server-7.2.0.0-1.5.99.1/hw/dmx/dmxscrinit.c
===================================================================
--- xorg-server-7.2.0.0-1.5.99.1.orig/hw/dmx/dmxscrinit.c
+++ xorg-server-7.2.0.0-1.5.99.1/hw/dmx/dmxscrinit.c
@@ -952,10 +952,10 @@ dmxScreenBlockHandler (pointer   blockDa
     DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
 
     if (dmxScreen->alive)
-    {
 	xcb_flush (dmxScreen->connection);
+
+    if (dmxScreen->beAttachedDisplay || dmxScreen->beDisplay)
 	dmxScreenCheckForIOError (pScreen);
-    }
 }
 
 static void
