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

View File

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

View File

@ -63,7 +63,7 @@ GetScratchPixmapHeader(ScreenPtr pScreen, int width, int height, int depth,
if ((*pScreen->ModifyPixmapHeader) (pPixmap, width, height, depth,
bitsPerPixel, devKind, pPixData))
return pPixmap;
(*pScreen->DestroyPixmap) (pPixmap);
dixDestroyPixmap(pPixmap, 0);
}
return NullPixmap;
}
@ -73,9 +73,8 @@ void
FreeScratchPixmapHeader(PixmapPtr pPixmap)
{
if (pPixmap) {
ScreenPtr pScreen = pPixmap->drawable.pScreen;
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);
if (ret == FALSE) {
secondary->DestroyPixmap(spix);
dixDestroyPixmap(spix, 0);
return NULL;
}

View File

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