]> Dogcows Code - chaz/openbox/commitdiff
fix a memleak reported by valgrind
authorDana Jansens <danakj@orodu.net>
Fri, 5 Jul 2002 19:48:03 +0000 (19:48 +0000)
committerDana Jansens <danakj@orodu.net>
Fri, 5 Jul 2002 19:48:03 +0000 (19:48 +0000)
src/XAtom.cc

index 62a8f710b3c770e7ea4e3958a11f464fda5ad620..c450fc4a7b79348ea322e56af56634f4bfdff1ee 100644 (file)
@@ -353,7 +353,7 @@ bool XAtom::getValue(Window win, Atom atom, Atom type,
   assert(win != None); assert(atom != None); assert(type != None);
   assert(size == 8 || size == 16 || size == 32);
   assert(nelements > 0);
-  unsigned char *c_val;        // value alloc'd with c malloc
+  unsigned char *c_val = 0;        // value alloc'd with c malloc
   Atom ret_type;
   int ret_size;
   unsigned long ret_bytes;
@@ -363,12 +363,11 @@ bool XAtom::getValue(Window win, Atom atom, Atom type,
   result = XGetWindowProperty(_display, win, atom, 0l, 1l, False,
                               AnyPropertyType, &ret_type, &ret_size,
                               &nelements, &ret_bytes, &c_val);
-  if (result != Success || ret_type == None || nelements < 1)
-    // an error occured, the property does not exist on the window, or is empty
-    return false;
-  if (ret_type != type || ret_size != size) {
-    // wrong data in property
-    XFree(c_val);
+  if (result != Success || ret_type != type || ret_size != size ||
+      nelements < 1) {
+    // an error occured, the property does not exist on the window, or is empty,
+    // or the wrong data is in property for the request
+    if (c_val) XFree(c_val);
     return false;
   }
   // the data is correct, now, is there more elements left?
This page took 0.026531 seconds and 4 git commands to generate.