Xext: composite: take the pixmap reference before AddResource() on Xinerama

When AddResource() fails it calls the type's delete function, which for
pixmaps is dixDestroyPixmap() and drops one reference.

SingleCompositeNameWindowPixmap() increments pPixmap->refcnt before
AddResource(), so a failure only drops that extra reference. The Xinerama
path in ProcCompositeNameWindowPixmap() incremented it afterwards, so a
failure dropped the window's own reference to its backing pixmap and
could free it while still in use. Take the reference first, as the
single-screen path does.

Signed-off-by: Mason Green <mason@greenm01.net>
This commit is contained in:
Mason Green 2026-10-09 11:33:47 -04:00 • committed by Enrico Weigelt
commit 73cd133bbb

View file

@ -637,12 +637,14 @@ ProcCompositeNameWindowPixmap(ClientPtr client)
return BadMatch;
}
/* take our reference first: on failure, AddResource() drops it again
through the pixmap delete function */
++pPixmap->refcnt;
if (!AddResource(newPix->info[walkScreenIdx].id, X11_RESTYPE_PIXMAP, (void *) pPixmap)) {
free(newPix);
return BadAlloc;
}
++pPixmap->refcnt;
});
if (!AddResource(stuff->pixmap, XRT_PIXMAP, (void *) newPix))