summaryrefslogtreecommitdiff
path: root/xcl
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2002-04-19 21:11:18 +0000
committerKeith Packard <keithp@keithp.com>2002-04-19 21:11:18 +0000
commit8e029d2d9b9753be5dccf72380dbc555d39694b7 (patch)
treef7aff374a732d3c5c26171fe20c3c969981d984a /xcl
parentafb9f945e6d743b76786da01a96efa0c71d5e210 (diff)
Fix GetProperty to use correct length
Diffstat (limited to 'xcl')
-rw-r--r--xcl/src/GetProp.c8
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;