Commit 7a8721b8 authored by Alan Coopersmith's avatar Alan Coopersmith Committed by Ulrich Sibiller

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: 's avatarAlan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: 's avatarAaron Plattner <aplattner@nvidia.com> Backported-to-NX-by: 's avatarUlrich Sibiller <uli42@gmx.de>
parent c8680614
......@@ -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;
......
......@@ -66,8 +66,11 @@ Pixmap XCreatePixmapFromBitmapData(
pix = XCreatePixmap(display, d, width, height, depth);
gcv.foreground = fg;
gcv.background = bg;
if (! (gc = XCreateGC(display, pix, GCForeground|GCBackground, &gcv)))
return (Pixmap) NULL;
gc = XCreateGC(display, pix, GCForeground|GCBackground, &gcv);
if (gc == NULL) {
XFreePixmap(display, pix);
return (Pixmap) None;
}
ximage.height = height;
ximage.width = width;
ximage.depth = 1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment