diff options
author | Keith Packard <keithp@keithp.com> | 2002-04-19 21:11:18 +0000 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2002-04-19 21:11:18 +0000 |
commit | 8e029d2d9b9753be5dccf72380dbc555d39694b7 (patch) | |
tree | f7aff374a732d3c5c26171fe20c3c969981d984a /xcl | |
parent | afb9f945e6d743b76786da01a96efa0c71d5e210 (diff) |
Fix GetProperty to use correct length
Diffstat (limited to 'xcl')
-rw-r--r-- | xcl/src/GetProp.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/xcl/src/GetProp.c b/xcl/src/GetProp.c index 83bd5c0..d950a47 100644 --- a/xcl/src/GetProp.c +++ b/xcl/src/GetProp.c @@ -20,6 +20,7 @@ XGetWindowProperty(register Display *dpy, Window window, Atom property, long off *prop = (unsigned char *) NULL; if (r->type.xid != None) { + long bytes; /* Check that the server returned a valid format. If it didn't, * throw a BadImplementation error in the library. */ switch (r->format) { @@ -43,13 +44,14 @@ XGetWindowProperty(register Display *dpy, Window window, Atom property, long off * returning string properties, so the client doesn't then have to * recopy the string to make it null terminated. On the other hand, * it's a really stupid idea. */ - *prop = Xmalloc (r->bytes_after + 1); + bytes = r->value_len * 8 / r->format; + *prop = Xmalloc (bytes + 1); if (!*prop) goto error; /* FIXME: Xlib has a different behavior than this for systems where a * short isn't 16 bits or where a long isn't 32 bits. */ - memcpy (*prop, XCBGetPropertyvalue(r), r->bytes_after); - (*prop)[r->bytes_after] = '\0'; + memcpy (*prop, XCBGetPropertyvalue(r), bytes); + (*prop)[bytes] = '\0'; } *actual_type = r->type.xid; |