From 7a8721b8a7c6d8b11f1223a8a06ccbfe97ad7352 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Fri, 29 Jun 2012 22:57:13 -0700 Subject: XCreate{Pix,Bit}map...Data: Free pixmap in error path if XCreateGC fails Fixes leaks in error paths found by Parfait 1.0.0: Error: X Resource Leak Leaked X Resource pix at line 62 of CrBFData.c in function 'XCreateBitmapFromData'. pix initialized at line 60 with XCreatePixmap Error: X Resource Leak Leaked X Resource pix at line 70 of CrPFBData.c in function 'XCreatePixmapFromBitmapData'. pix initialized at line 66 with XCreatePixmap Signed-off-by: Alan Coopersmith Reviewed-by: Aaron Plattner Backported-to-NX-by: Ulrich Sibiller --- nx-X11/lib/X11/CrBFData.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'nx-X11/lib/X11/CrBFData.c') diff --git a/nx-X11/lib/X11/CrBFData.c b/nx-X11/lib/X11/CrBFData.c index 449095690..95158755f 100644 --- a/nx-X11/lib/X11/CrBFData.c +++ b/nx-X11/lib/X11/CrBFData.c @@ -58,8 +58,11 @@ Pixmap XCreateBitmapFromData( Pixmap pix; pix = XCreatePixmap(display, d, width, height, 1); - if (! (gc = XCreateGC(display, pix, (unsigned long) 0, (XGCValues *) 0))) - return (Pixmap) None; + gc = XCreateGC(display, pix, (unsigned long) 0, (XGCValues *) 0); + if (gc == NULL) { + XFreePixmap(display, pix); + return (Pixmap) None; + } ximage.height = height; ximage.width = width; ximage.depth = 1; -- cgit v1.2.3