all repos — openbox @ b3c31573549281a9d893f400a41dba5268de7165

openbox fork - make it a bit more like ryudo

fix a memleak reported by valgrind
Dana Jansens danakj@orodu.net
commit

b3c31573549281a9d893f400a41dba5268de7165

parent

6954842d84539c1b345d575a39c5dbd5ab0a1227

1 files changed, 6 insertions(+), 7 deletions(-)

jump to
M src/XAtom.ccsrc/XAtom.cc

@@ -353,7 +353,7 @@ int size) const {

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 @@ // try get the first element

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?