dri2: Only deal with output windows and pixmaps.

This reverts commit fdb081b430
"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 <daenzer@vmware.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
This commit is contained in:
Keith Packard 2010-06-10 07:15:49 -07:00
parent 353e32d371
commit 4172aa137c
2 changed files with 12 additions and 7 deletions

View File

@ -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;

View File

@ -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;