summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2014-12-31 00:24:49 -0800
committerAlan Coopersmith <alan.coopersmith@oracle.com>2015-01-05 09:40:40 -0800
commit7c0c3afd6f5bfc02fd98a2da03f7fb7d6567ccf3 (patch)
tree179f2a918574441f6b6e26351701f8aad8ed9d17
parenteeebd3cd6bb4373ca6da5c0b6d5caa1a41d5bffc (diff)
Only use property pointer if XGetWindowProperty returns success
In Xlib versions prior to 1.6, if XGetWindowProperty returns a failure, it didn't always set the property pointer to NULL, and could leave it uninitialized. Reported by Oracle Parfait 1.5.1: Error: Uninitialised memory (CWE 456) Possible access to uninitialised memory '&data' at line 298 of transSet.c in function 'main'. &data allocated at line 154. at line 299 of transSet.c in function 'main'. &data allocated at line 154. at line 300 of transSet.c in function 'main'. &data allocated at line 154. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
-rw-r--r--transSet.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/transSet.c b/transSet.c
index 9938e79..04c40e4 100644
--- a/transSet.c
+++ b/transSet.c
@@ -291,11 +291,10 @@ main (int argc, char **argv)
}
/* get property */
- XGetWindowProperty (dpy, target_win, XInternAtom (dpy, OPACITY, False),
- 0L, 1L, False, XA_CARDINAL, &actual, &format, &n, &left,
- (unsigned char **) &data);
-
- if (data != None) {
+ if ((XGetWindowProperty (dpy, target_win, XInternAtom (dpy, OPACITY, False),
+ 0L, 1L, False, XA_CARDINAL, &actual, &format, &n,
+ &left, &data) == Success)
+ && (data != None)) {
memcpy (&current_opacity, data, sizeof (unsigned int));
XFree ((void *) data);
if (flag_verbose)