From 4172aa137c1b9b6f2a25c320d847af1f5ac56fba Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 10 Jun 2010 07:15:49 -0700 Subject: [PATCH] dri2: Only deal with output windows and pixmaps. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit fdb081b430ddffb495aa5b05bcc4cf10882ff4b2 "dri2: Deal with input-only windows by using WindowDrawable()" and replaces it as follows: Reject the creation of a DRI2 drawable for UNDRAWABLE_WINDOW (input-only windows) and DRAWABLE_BUFFER (whatever those are) drawables and only look up privates for the supported drawable types. The rest of the the code can continue pretending there's only output windows and pixmaps, which are the only kinds of drawables relevant for DRI2. Fixes server crash with GLX compositing managers such as compiz or kwin, due to looking up a window private for a pixmap and getting a bogus pointer. Signed-off-by: Michel Dänzer Reviewed-by: Keith Packard Signed-off-by: Keith Packard --- hw/xfree86/dri2/dri2.c | 15 +++++++++------ hw/xfree86/dri2/dri2ext.c | 4 +++- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c index 0687202a99..27d8e25378 100644 --- a/hw/xfree86/dri2/dri2.c +++ b/hw/xfree86/dri2/dri2.c @@ -118,12 +118,15 @@ DRI2GetDrawable(DrawablePtr pDraw) WindowPtr pWin; PixmapPtr pPixmap; - if (WindowDrawable(pDraw->type)) { + switch (pDraw->type) { + case DRAWABLE_WINDOW: pWin = (WindowPtr) pDraw; return dixLookupPrivate(&pWin->devPrivates, dri2WindowPrivateKey); - } else { + case DRAWABLE_PIXMAP: pPixmap = (PixmapPtr) pDraw; return dixLookupPrivate(&pPixmap->devPrivates, dri2PixmapPrivateKey); + default: + return NULL; } } @@ -161,7 +164,7 @@ DRI2AllocateDrawable(DrawablePtr pDraw) pPriv->last_swap_ust = 0; list_init(&pPriv->reference_list); - if (WindowDrawable(pDraw->type)) { + if (pDraw->type == DRAWABLE_WINDOW) { pWin = (WindowPtr) pDraw; dixSetPrivate(&pWin->devPrivates, dri2WindowPrivateKey, pPriv); } else { @@ -272,7 +275,7 @@ static int DRI2DrawableGone(pointer p, XID id) return Success; pDraw = pPriv->drawable; - if (WindowDrawable(pDraw->type)) { + if (pDraw->type == DRAWABLE_WINDOW) { pWin = (WindowPtr) pDraw; dixSetPrivate(&pWin->devPrivates, dri2WindowPrivateKey, NULL); } else { @@ -411,12 +414,12 @@ do_get_buffers(DrawablePtr pDraw, int *width, int *height, need_real_front--; front_format = format; - if (WindowDrawable(pDraw->type)) { + if (pDraw->type == DRAWABLE_WINDOW) { need_fake_front++; } } - if (WindowDrawable(pDraw->type)) { + if (pDraw->type == DRAWABLE_WINDOW) { if (attachment == DRI2BufferFakeFrontLeft) { need_fake_front--; have_fake_front = 1; diff --git a/hw/xfree86/dri2/dri2ext.c b/hw/xfree86/dri2/dri2ext.c index 8016edb3ff..4e48e65b21 100644 --- a/hw/xfree86/dri2/dri2ext.c +++ b/hw/xfree86/dri2/dri2ext.c @@ -55,7 +55,9 @@ static Bool validDrawable(ClientPtr client, XID drawable, Mask access_mode, DrawablePtr *pDrawable, int *status) { - *status = dixLookupDrawable(pDrawable, drawable, client, 0, access_mode); + *status = dixLookupDrawable(pDrawable, drawable, client, + M_DRAWABLE_WINDOW | M_DRAWABLE_PIXMAP, + access_mode); if (*status != Success) { client->errorValue = drawable; return FALSE;