[prev in list] [next in list] [prev in thread] [next in thread]
List: freedesktop-xorg-devel
Subject: [PATCH:libX11 1/2] XCreate{Pix, Bit}map...Data: Free pixmap in error path if XCreateGC fails
From: Alan Coopersmith <alan.coopersmith () oracle ! com>
Date: 2012-06-30 6:11:06
Message-ID: 1341036667-7223-1-git-send-email-alan.coopersmith () oracle ! com
[Download RAW message or body]
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>
---
src/CrBFData.c | 7 +++++--
src/CrPFBData.c | 7 +++++--
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/src/CrBFData.c b/src/CrBFData.c
index 4490956..9515875 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 57cd153..d343420 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;
--
1.7.9.2
_______________________________________________
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic