dix: use dixDestroyPixmap() instead of direct driver call

Direct calls to ScreenRec->DestroyPixmap() blocks cleaning up the wrapping
jungle, so use the proper dix function instead.

See: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1754

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1711>
This commit is contained in:
Enrico Weigelt, metux IT consult 2024-09-30 17:52:07 +02:00
parent c0f3b5bcef
commit 5b541780c1
5 changed files with 24 additions and 28 deletions

View File

@ -1524,7 +1524,7 @@ ProcCreatePixmap(ClientPtr client)
rc = XaceHookResourceAccess(client, stuff->pid, X11_RESTYPE_PIXMAP, rc = XaceHookResourceAccess(client, stuff->pid, X11_RESTYPE_PIXMAP,
pMap, X11_RESTYPE_NONE, NULL, DixCreateAccess); pMap, X11_RESTYPE_NONE, NULL, DixCreateAccess);
if (rc != Success) { if (rc != Success) {
(*pDraw->pScreen->DestroyPixmap) (pMap); dixDestroyPixmap(pMap, 0);
return rc; return rc;
} }
if (AddResource(stuff->pid, X11_RESTYPE_PIXMAP, (void *) pMap)) if (AddResource(stuff->pid, X11_RESTYPE_PIXMAP, (void *) pMap))

View File

@ -254,7 +254,7 @@ ChangeGC(ClientPtr client, GC * pGC, BITS32 mask, ChangeGCValPtr pUnion)
else { else {
pPixmap->refcnt++; pPixmap->refcnt++;
if (!pGC->tileIsPixel) if (!pGC->tileIsPixel)
(*pGC->pScreen->DestroyPixmap) (pGC->tile.pixmap); dixDestroyPixmap(pGC->tile.pixmap, 0);
pGC->tileIsPixel = FALSE; pGC->tileIsPixel = FALSE;
pGC->tile.pixmap = pPixmap; pGC->tile.pixmap = pPixmap;
} }
@ -271,7 +271,7 @@ ChangeGC(ClientPtr client, GC * pGC, BITS32 mask, ChangeGCValPtr pUnion)
if (pPixmap) if (pPixmap)
pPixmap->refcnt++; pPixmap->refcnt++;
if (pGC->stipple) if (pGC->stipple)
(*pGC->pScreen->DestroyPixmap) (pGC->stipple); dixDestroyPixmap(pGC->stipple, 0);
pGC->stipple = pPixmap; pGC->stipple = pPixmap;
} }
break; break;
@ -588,8 +588,7 @@ CreateDefaultTile(GCPtr pGC)
(*pGC->pScreen->CreatePixmap) (pGC->pScreen, w, h, pGC->depth, 0); (*pGC->pScreen->CreatePixmap) (pGC->pScreen, w, h, pGC->depth, 0);
pgcScratch = GetScratchGC(pGC->depth, pGC->pScreen); pgcScratch = GetScratchGC(pGC->depth, pGC->pScreen);
if (!pTile || !pgcScratch) { if (!pTile || !pgcScratch) {
if (pTile) dixDestroyPixmap(pTile, 0);
(*pTile->drawable.pScreen->DestroyPixmap) (pTile);
if (pgcScratch) if (pgcScratch)
FreeScratchGC(pgcScratch); FreeScratchGC(pgcScratch);
return FALSE; return FALSE;
@ -668,7 +667,7 @@ CopyGC(GC * pgcSrc, GC * pgcDst, BITS32 mask)
break; break;
} }
if (!pgcDst->tileIsPixel) if (!pgcDst->tileIsPixel)
(*pgcDst->pScreen->DestroyPixmap) (pgcDst->tile.pixmap); dixDestroyPixmap(pgcDst->tile.pixmap, 0);
pgcDst->tileIsPixel = pgcSrc->tileIsPixel; pgcDst->tileIsPixel = pgcSrc->tileIsPixel;
pgcDst->tile = pgcSrc->tile; pgcDst->tile = pgcSrc->tile;
if (!pgcDst->tileIsPixel) if (!pgcDst->tileIsPixel)
@ -680,7 +679,7 @@ CopyGC(GC * pgcSrc, GC * pgcDst, BITS32 mask)
if (pgcDst->stipple == pgcSrc->stipple) if (pgcDst->stipple == pgcSrc->stipple)
break; break;
if (pgcDst->stipple) if (pgcDst->stipple)
(*pgcDst->pScreen->DestroyPixmap) (pgcDst->stipple); dixDestroyPixmap(pgcDst->stipple, 0);
pgcDst->stipple = pgcSrc->stipple; pgcDst->stipple = pgcSrc->stipple;
if (pgcDst->stipple) if (pgcDst->stipple)
pgcDst->stipple->refcnt++; pgcDst->stipple->refcnt++;
@ -775,9 +774,9 @@ FreeGC(void *value, XID gid)
(*pGC->funcs->DestroyClip) (pGC); (*pGC->funcs->DestroyClip) (pGC);
if (!pGC->tileIsPixel) if (!pGC->tileIsPixel)
(*pGC->pScreen->DestroyPixmap) (pGC->tile.pixmap); dixDestroyPixmap(pGC->tile.pixmap, 0);
if (pGC->stipple) if (pGC->stipple)
(*pGC->pScreen->DestroyPixmap) (pGC->stipple); dixDestroyPixmap(pGC->stipple, 0);
if (pGC->funcs) if (pGC->funcs)
(*pGC->funcs->DestroyGC) (pGC); (*pGC->funcs->DestroyGC) (pGC);
@ -885,7 +884,7 @@ CreateDefaultStipple(int screenNum)
tmpval[2].val = FillSolid; tmpval[2].val = FillSolid;
pgcScratch = GetScratchGC(1, pScreen); pgcScratch = GetScratchGC(1, pScreen);
if (!pgcScratch) { if (!pgcScratch) {
(*pScreen->DestroyPixmap) (pScreen->defaultStipple); dixDestroyPixmap(pScreen->defaultStipple, 0);
return FALSE; return FALSE;
} }
(void) ChangeGC(NullClient, pgcScratch, (void) ChangeGC(NullClient, pgcScratch,
@ -905,8 +904,7 @@ void
FreeDefaultStipple(int screenNum) FreeDefaultStipple(int screenNum)
{ {
ScreenPtr pScreen = screenInfo.screens[screenNum]; ScreenPtr pScreen = screenInfo.screens[screenNum];
dixDestroyPixmap(pScreen->defaultStipple, 0);
(*pScreen->DestroyPixmap) (pScreen->defaultStipple);
} }
int int

View File

@ -96,8 +96,7 @@ ServerBitsFromGlyph(FontPtr pfont, unsigned ch, CursorMetricPtr cm,
CREATE_PIXMAP_USAGE_SCRATCH); CREATE_PIXMAP_USAGE_SCRATCH);
pGC = GetScratchGC(1, pScreen); pGC = GetScratchGC(1, pScreen);
if (!ppix || !pGC) { if (!ppix || !pGC) {
if (ppix) dixDestroyPixmap(ppix, 0);
(*pScreen->DestroyPixmap) (ppix);
if (pGC) if (pGC)
FreeScratchGC(pGC); FreeScratchGC(pGC);
free(pbits); free(pbits);
@ -127,7 +126,7 @@ ServerBitsFromGlyph(FontPtr pfont, unsigned ch, CursorMetricPtr cm,
XYPixmap, 1, pbits); XYPixmap, 1, pbits);
*ppbits = (unsigned char *) pbits; *ppbits = (unsigned char *) pbits;
FreeScratchGC(pGC); FreeScratchGC(pGC);
(*pScreen->DestroyPixmap) (ppix); dixDestroyPixmap(ppix, 0);
return Success; return Success;
} }

View File

@ -63,7 +63,7 @@ GetScratchPixmapHeader(ScreenPtr pScreen, int width, int height, int depth,
if ((*pScreen->ModifyPixmapHeader) (pPixmap, width, height, depth, if ((*pScreen->ModifyPixmapHeader) (pPixmap, width, height, depth,
bitsPerPixel, devKind, pPixData)) bitsPerPixel, devKind, pPixData))
return pPixmap; return pPixmap;
(*pScreen->DestroyPixmap) (pPixmap); dixDestroyPixmap(pPixmap, 0);
} }
return NullPixmap; return NullPixmap;
} }
@ -73,9 +73,8 @@ void
FreeScratchPixmapHeader(PixmapPtr pPixmap) FreeScratchPixmapHeader(PixmapPtr pPixmap)
{ {
if (pPixmap) { if (pPixmap) {
ScreenPtr pScreen = pPixmap->drawable.pScreen;
pPixmap->devPrivate.ptr = NULL; /* help catch/avoid heap-use-after-free */ pPixmap->devPrivate.ptr = NULL; /* help catch/avoid heap-use-after-free */
(*pScreen->DestroyPixmap)(pPixmap); dixDestroyPixmap(pPixmap, 0);
} }
} }
@ -151,7 +150,7 @@ PixmapPtr PixmapShareToSecondary(PixmapPtr pixmap, ScreenPtr secondary)
ret = secondary->SetSharedPixmapBacking(spix, handle); ret = secondary->SetSharedPixmapBacking(spix, handle);
if (ret == FALSE) { if (ret == FALSE) {
secondary->DestroyPixmap(spix); dixDestroyPixmap(spix, 0);
return NULL; return NULL;
} }

View File

@ -1014,9 +1014,9 @@ FreeWindowResources(WindowPtr pWin)
if (wInputShape(pWin)) if (wInputShape(pWin))
RegionDestroy(wInputShape(pWin)); RegionDestroy(wInputShape(pWin));
if (pWin->borderIsPixel == FALSE) if (pWin->borderIsPixel == FALSE)
(*pScreen->DestroyPixmap) (pWin->border.pixmap); dixDestroyPixmap(pWin->border.pixmap, 0);
if (pWin->backgroundState == BackgroundPixmap) if (pWin->backgroundState == BackgroundPixmap)
(*pScreen->DestroyPixmap) (pWin->background.pixmap); dixDestroyPixmap(pWin->background.pixmap, 0);
DeleteAllWindowProperties(pWin); DeleteAllWindowProperties(pWin);
/* We SHOULD check for an error value here XXX */ /* We SHOULD check for an error value here XXX */
@ -1195,7 +1195,7 @@ ChangeWindowAttributes(WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client)
borderRelative = TRUE; borderRelative = TRUE;
if (pixID == None) { if (pixID == None) {
if (pWin->backgroundState == BackgroundPixmap) if (pWin->backgroundState == BackgroundPixmap)
(*pScreen->DestroyPixmap) (pWin->background.pixmap); dixDestroyPixmap(pWin->background.pixmap, 0);
if (!pWin->parent) if (!pWin->parent)
SetRootWindowBackground(pWin, pScreen, &index2); SetRootWindowBackground(pWin, pScreen, &index2);
else { else {
@ -1210,7 +1210,7 @@ ChangeWindowAttributes(WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client)
goto PatchUp; goto PatchUp;
} }
if (pWin->backgroundState == BackgroundPixmap) if (pWin->backgroundState == BackgroundPixmap)
(*pScreen->DestroyPixmap) (pWin->background.pixmap); dixDestroyPixmap(pWin->background.pixmap, 0);
if (!pWin->parent) if (!pWin->parent)
SetRootWindowBackground(pWin, pScreen, &index2); SetRootWindowBackground(pWin, pScreen, &index2);
else else
@ -1229,7 +1229,7 @@ ChangeWindowAttributes(WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client)
goto PatchUp; goto PatchUp;
} }
if (pWin->backgroundState == BackgroundPixmap) if (pWin->backgroundState == BackgroundPixmap)
(*pScreen->DestroyPixmap) (pWin->background.pixmap); dixDestroyPixmap(pWin->background.pixmap, 0);
pWin->backgroundState = BackgroundPixmap; pWin->backgroundState = BackgroundPixmap;
pWin->background.pixmap = pPixmap; pWin->background.pixmap = pPixmap;
pPixmap->refcnt++; pPixmap->refcnt++;
@ -1245,7 +1245,7 @@ ChangeWindowAttributes(WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client)
if (pWin->backgroundState == ParentRelative) if (pWin->backgroundState == ParentRelative)
borderRelative = TRUE; borderRelative = TRUE;
if (pWin->backgroundState == BackgroundPixmap) if (pWin->backgroundState == BackgroundPixmap)
(*pScreen->DestroyPixmap) (pWin->background.pixmap); dixDestroyPixmap(pWin->background.pixmap, 0);
pWin->backgroundState = BackgroundPixel; pWin->backgroundState = BackgroundPixel;
pWin->background.pixel = (CARD32) *pVlist; pWin->background.pixel = (CARD32) *pVlist;
/* background pixel overrides background pixmap, /* background pixel overrides background pixmap,
@ -1264,7 +1264,7 @@ ChangeWindowAttributes(WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client)
} }
if (pWin->parent->borderIsPixel == TRUE) { if (pWin->parent->borderIsPixel == TRUE) {
if (pWin->borderIsPixel == FALSE) if (pWin->borderIsPixel == FALSE)
(*pScreen->DestroyPixmap) (pWin->border.pixmap); dixDestroyPixmap(pWin->border.pixmap, 0);
pWin->border = pWin->parent->border; pWin->border = pWin->parent->border;
pWin->borderIsPixel = TRUE; pWin->borderIsPixel = TRUE;
index2 = CWBorderPixel; index2 = CWBorderPixel;
@ -1283,7 +1283,7 @@ ChangeWindowAttributes(WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client)
goto PatchUp; goto PatchUp;
} }
if (pWin->borderIsPixel == FALSE) if (pWin->borderIsPixel == FALSE)
(*pScreen->DestroyPixmap) (pWin->border.pixmap); dixDestroyPixmap(pWin->border.pixmap, 0);
pWin->borderIsPixel = FALSE; pWin->borderIsPixel = FALSE;
pWin->border.pixmap = pPixmap; pWin->border.pixmap = pPixmap;
pPixmap->refcnt++; pPixmap->refcnt++;
@ -1296,7 +1296,7 @@ ChangeWindowAttributes(WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client)
break; break;
case CWBorderPixel: case CWBorderPixel:
if (pWin->borderIsPixel == FALSE) if (pWin->borderIsPixel == FALSE)
(*pScreen->DestroyPixmap) (pWin->border.pixmap); dixDestroyPixmap(pWin->border.pixmap, 0);
pWin->borderIsPixel = TRUE; pWin->borderIsPixel = TRUE;
pWin->border.pixel = (CARD32) *pVlist; pWin->border.pixel = (CARD32) *pVlist;
/* border pixel overrides border pixmap, /* border pixel overrides border pixmap,