From 23e7de97c8f1151655547ba7e87d33b86d046707 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 17 Apr 2026 10:32:16 +1000 Subject: [PATCH] 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: --- render/render.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/render/render.c b/render/render.c index fde156593..1efe11862 100644 --- a/render/render.c +++ b/render/render.c @@ -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;