render: fix memory leaks on XaceHook failure in resource creation

Same pattern for all hunks here: if Xace fails, free the
allocated data.

Assisted-by: Claude:claude-claude-opus-4-6
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2205>
This commit is contained in:
Peter Hutterer 2026-04-17 10:32:16 +10:00 committed by Marge Bot
parent 634247ef0c
commit 23e7de97c8

View file

@ -931,8 +931,10 @@ ProcRenderCreateGlyphSet(ClientPtr client)
/* security creation/labeling check */
rc = XaceHookResourceAccess(client, stuff->gsid, GlyphSetType,
glyphSet, X11_RESTYPE_NONE, NULL, DixCreateAccess);
if (rc != Success)
if (rc != Success) {
FreeGlyphSet(glyphSet, (XID) 0);
return rc;
}
if (!AddResource(stuff->gsid, GlyphSetType, (void *) glyphSet))
return BadAlloc;
return Success;
@ -1866,8 +1868,10 @@ ProcRenderCreateSolidFill(ClientPtr client)
/* security creation/labeling check */
error = XaceHookResourceAccess(client, stuff->pid, PictureType,
pPicture, X11_RESTYPE_NONE, NULL, DixCreateAccess);
if (error != Success)
if (error != Success) {
FreePicture(pPicture, (XID) 0);
return error;
}
if (!AddResource(stuff->pid, PictureType, (void *) pPicture))
return BadAlloc;
return Success;
@ -1905,8 +1909,10 @@ ProcRenderCreateLinearGradient(ClientPtr client)
/* security creation/labeling check */
error = XaceHookResourceAccess(client, stuff->pid, PictureType,
pPicture, X11_RESTYPE_NONE, NULL, DixCreateAccess);
if (error != Success)
if (error != Success) {
FreePicture(pPicture, (XID) 0);
return error;
}
if (!AddResource(stuff->pid, PictureType, (void *) pPicture))
return BadAlloc;
return Success;
@ -1945,8 +1951,10 @@ ProcRenderCreateRadialGradient(ClientPtr client)
/* security creation/labeling check */
error = XaceHookResourceAccess(client, stuff->pid, PictureType,
pPicture, X11_RESTYPE_NONE, NULL, DixCreateAccess);
if (error != Success)
if (error != Success) {
FreePicture(pPicture, (XID) 0);
return error;
}
if (!AddResource(stuff->pid, PictureType, (void *) pPicture))
return BadAlloc;
return Success;
@ -1984,8 +1992,10 @@ ProcRenderCreateConicalGradient(ClientPtr client)
/* security creation/labeling check */
error = XaceHookResourceAccess(client, stuff->pid, PictureType,
pPicture, X11_RESTYPE_NONE, NULL, DixCreateAccess);
if (error != Success)
if (error != Success) {
FreePicture(pPicture, (XID) 0);
return error;
}
if (!AddResource(stuff->pid, PictureType, (void *) pPicture))
return BadAlloc;
return Success;