diff -rupN a/nouveau_wfb.c b/nouveau_wfb.c
--- a/nouveau_wfb.c	2009-06-24 21:58:42.583403634 +0200
+++ b/nouveau_wfb.c	2009-06-24 21:59:03.213097483 +0200
@@ -175,20 +175,21 @@ nouveau_wfb_setup_wrap(ReadMemoryProcPtr
 void
 nouveau_wfb_finish_wrap(DrawablePtr pDraw)
 {
-	struct wfb_pixmap *wfb = &wfb_pixmap[0];
+	struct wfb_pixmap *wfb;
 	PixmapPtr ppix;
-	int i;
+	int i,wrap;
 
 	ppix = NVGetDrawablePixmap(pDraw);
 	if (!ppix)
 		return;
 
-	for (i = 0; i < 6; i++) {
-		if (wfb->ppix != ppix)
-			continue;
+	wfb = &wfb_pixmap[0];
 
+	wrap = 0;
+	while(wfb_pixmap[wrap].ppix) {
+		wfb = &wfb_pixmap[wrap];
 		wfb->ppix = NULL;
-		break;
+		wrap++;
 	}
 }
 
