aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/lib
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2012-06-29 22:57:13 -0700
committerUlrich Sibiller <uli42@gmx.de>2016-10-19 21:40:26 +0200
commit7a8721b8a7c6d8b11f1223a8a06ccbfe97ad7352 (patch)
treeda06fe5cfab0cede28dc60dc364c65cc53cc3178 /nx-X11/lib
parentc868061482102f68353a1eea7fdf275f0cd2600b (diff)
downloadnx-libs-7a8721b8a7c6d8b11f1223a8a06ccbfe97ad7352.tar.gz
nx-libs-7a8721b8a7c6d8b11f1223a8a06ccbfe97ad7352.tar.bz2
nx-libs-7a8721b8a7c6d8b11f1223a8a06ccbfe97ad7352.zip
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> Backported-to-NX-by: Ulrich Sibiller <uli42@gmx.de>
Diffstat (limited to 'nx-X11/lib')
-rw-r--r--nx-X11/lib/X11/CrBFData.c7
-rw-r--r--nx-X11/lib/X11/CrPFBData.c7
2 files changed, 10 insertions, 4 deletions
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;
diff --git a/nx-X11/lib/X11/CrPFBData.c b/nx-X11/lib/X11/CrPFBData.c
index 57cd15303..d343420aa 100644
--- a/nx-X11/lib/X11/CrPFBData.c
+++ b/nx-X11/lib/X11/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;