summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2012-06-29 22:57:13 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2012-07-08 09:17:22 -0700
commit0dc93f7e43deb102b1f8fb7c4c4844cdce7ffd1e (patch)
tree4f601e4e7f6ba2fa13f04445343a9a60dda9d2cd
parentdce84b8c39ad5a8908c29bb6de25b6c3004c1ab7 (diff)
downloadxorg-lib-libX11-0dc93f7e43deb102b1f8fb7c4c4844cdce7ffd1e.tar.gz
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 <alan.coopersmith@oracle.com> Reviewed-by: Aaron Plattner <aplattner@nvidia.com>
-rw-r--r--src/CrBFData.c7
-rw-r--r--src/CrPFBData.c7
2 files changed, 10 insertions, 4 deletions
diff --git a/src/CrBFData.c b/src/CrBFData.c
index 44909569..95158755 100644
--- a/src/CrBFData.c
+++ b/src/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;
diff --git a/src/CrPFBData.c b/src/CrPFBData.c
index 57cd1530..d343420a 100644
--- a/src/CrPFBData.c
+++ b/src/CrPFBData.c
@@ -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;