summaryrefslogtreecommitdiffstats
path: root/util/IMdkit/i18nX.c
diff options
context:
space:
mode:
Diffstat (limited to 'util/IMdkit/i18nX.c')
-rw-r--r--util/IMdkit/i18nX.c41
1 files changed, 9 insertions, 32 deletions
diff --git a/util/IMdkit/i18nX.c b/util/IMdkit/i18nX.c
index df0edec..a5ba080 100644
--- a/util/IMdkit/i18nX.c
+++ b/util/IMdkit/i18nX.c
@@ -29,7 +29,6 @@ IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
******************************************************************/
-#include <limits.h>
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include "FrameMgr.h"
@@ -129,7 +128,6 @@ static unsigned char *ReadXIMMessage (XIMS ims,
else if (ev->format == 32) {
/* ClientMessage and WindowProperty */
unsigned long length = (unsigned long) ev->data.l[0];
- unsigned long get_length;
Atom atom = (Atom) ev->data.l[1];
int return_code;
Atom actual_type_ret;
@@ -138,20 +136,11 @@ static unsigned char *ReadXIMMessage (XIMS ims,
unsigned char *prop;
unsigned long nitems;
- /* Round up length to next 4 byte value. */
- get_length = length + 3;
- if (get_length > LONG_MAX)
- get_length = LONG_MAX;
- get_length /= 4;
- if (get_length == 0) {
- fprintf(stderr, "%s: invalid length 0\n", __FUNCTION__);
- return NULL;
- }
return_code = XGetWindowProperty (i18n_core->address.dpy,
x_client->accept_win,
atom,
- client->property_offset / 4,
- get_length,
+ 0L,
+ length,
True,
AnyPropertyType,
&actual_type_ret,
@@ -162,27 +151,15 @@ static unsigned char *ReadXIMMessage (XIMS ims,
if (return_code != Success || actual_format_ret == 0 || nitems == 0) {
if (return_code == Success)
XFree (prop);
- client->property_offset = 0;
return (unsigned char *) NULL;
}
- /* Update the offset to read next time as needed */
- if (bytes_after_ret > 0)
- client->property_offset += length;
- else
- client->property_offset = 0;
- switch (actual_format_ret) {
- case 8:
- case 16:
- case 32:
- length = nitems * actual_format_ret / 8;
- break;
- default:
- fprintf(stderr, "%s: unknown property return format: %d\n",
- __FUNCTION__, actual_format_ret);
- XFree(prop);
- client->property_offset = 0;
- return NULL;
- }
+ if (length != nitems)
+ length = nitems;
+ if (actual_format_ret == 16)
+ length *= 2;
+ else if (actual_format_ret == 32)
+ length *= 4;
+
/* if hit, it might be an error */
if ((p = (unsigned char *) malloc (length)) == NULL)
return (unsigned char *) NULL;