Skip to content

Commit 585110e

Browse files
Mikhail Dmitrichenkometux
authored andcommitted
composite: fix potential mem leak in PanoramiXCompositeNameWindowPixmap
newPix leaks if AddResource() call failes inside the FOR_NSCREENS loop (per-screen pixmap IDs). free newPix in mentioned execution path to prevent potential leak. Found by Linux Verification Center (linuxtesting.org) with SVACE. Signed-off-by: Mikhail Dmitrichenko <m.dmitrichenko222@gmail.com> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2173>
1 parent 49689fb commit 585110e

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

composite/compext.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -761,8 +761,10 @@ ProcCompositeNameWindowPixmap(ClientPtr client)
761761
return BadMatch;
762762
}
763763

764-
if (!AddResource(newPix->info[i].id, X11_RESTYPE_PIXMAP, (void *) pPixmap))
764+
if (!AddResource(newPix->info[i].id, X11_RESTYPE_PIXMAP, (void *) pPixmap)) {
765+
free(newPix);
765766
return BadAlloc;
767+
}
766768

767769
++pPixmap->refcnt;
768770
}

0 commit comments

Comments
 (0)