From 73cd133bbb30d45e92e2ab9d6cfa6d2ae5e18681 Mon Sep 17 00:00:00 2001 From: Mason Green Date: Fri, 9 Oct 2026 11:33:47 -0400 Subject: [PATCH] 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 --- Xext/composite/compext.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Xext/composite/compext.c b/Xext/composite/compext.c index 220df8abb6..4b8b43a728 100644 --- a/Xext/composite/compext.c +++ b/Xext/composite/compext.c @@ -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))