Hi,

On 03-01-15 23:29, Alan Coopersmith wrote:
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 <[email protected]>

Looks good:

Reviewed-by: Hans de Goede <[email protected]>

Regards,

Hans

---
  transSet.c |    9 ++++-----
  1 file 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)

_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to