From 11847e2ab410fa7f47cb3d41ce6c2b64200e7dc7 Mon Sep 17 00:00:00 2001 From: Emanuele Giaquinta Date: Mon, 25 Apr 2011 10:38:17 -0700 Subject: [PATCH] XQuartz: pbproxy: LP64: Fix itteration through XGetWindowProperty where sizeof(long) != 4 http://xquartz.macosforge.org/trac/ticket/476 Signed-off-by: Emanuele Giaquinta Reviewed-by: Jeremy Huddleston (cherry picked from commit 72ed7551f494c61283a7ac3d7b570eac39cc9786) --- hw/xquartz/pbproxy/x-selection.m | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/hw/xquartz/pbproxy/x-selection.m b/hw/xquartz/pbproxy/x-selection.m index ef84f8bfb..ed4b754b4 100644 --- a/hw/xquartz/pbproxy/x-selection.m +++ b/hw/xquartz/pbproxy/x-selection.m @@ -175,7 +175,12 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato #endif /* Format is the number of bits. */ - chunkbytesize = numitems * (format / 8); + if (format == 8) + chunkbytesize = numitems; + else if (format == 16) + chunkbytesize = numitems * sizeof(short); + else if (format == 32) + chunkbytesize = numitems * sizeof(long); #ifdef TEST printf("chunkbytesize %zu\n", chunkbytesize); @@ -235,9 +240,9 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato return None; } - for (i = 0, step = pdata->format >> 3; i < pdata->length; i += step) + for (i = 0, step = sizeof(long); i < pdata->length; i += step) { - a = (Atom)*(uint32_t *)(pdata->data + i); + a = (Atom)*(long *)(pdata->data + i); if (a == atoms->image_png) {