~ubuntu-branches/ubuntu/wily/scim/wily-proposed

« back to all changes in this revision

Viewing changes to modules/FrontEnd/IMdkit/i18nX.c

  • Committer: Bazaar Package Importer
  • Author(s): Rolf Leggewie
  • Date: 2010-08-11 18:28:44 UTC
  • mfrom: (3.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20100811182844-rnn95k63cwehtm75
Tags: 1.4.9-5
* debian/copyright: add my copyright
* debian/control: update to standard 3.9.1, no further changes necessary

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
 
30
30
******************************************************************/
31
31
 
 
32
#include <limits.h>
32
33
#include <X11/Xlib.h>
33
34
#include <X11/Xatom.h>
34
35
#include "FrameMgr.h"
128
129
    else if (ev->format == 32) {
129
130
        /* ClientMessage and WindowProperty */
130
131
        unsigned long length = (unsigned long) ev->data.l[0];
 
132
        unsigned long get_length;
131
133
        Atom atom = (Atom) ev->data.l[1];
132
134
        int     return_code;
133
135
        Atom    actual_type_ret;
136
138
        unsigned char *prop;
137
139
        unsigned long nitems;
138
140
 
 
141
        /* Round up length to next 4 byte value. */
 
142
        get_length = length + 3;
 
143
        if (get_length > LONG_MAX)
 
144
                get_length = LONG_MAX;
 
145
        get_length /= 4;
 
146
        if (get_length == 0) {
 
147
                fprintf(stderr, "%s: invalid length 0\n", __FUNCTION__);
 
148
                return NULL;
 
149
        }
139
150
        return_code = XGetWindowProperty (i18n_core->address.dpy,
140
151
                                          x_client->accept_win,
141
152
                                          atom,
142
 
                                          0L,
143
 
                                          length,
 
153
                                          client->property_offset / 4,
 
154
                                          get_length,
144
155
                                          True,
145
156
                                          AnyPropertyType,
146
157
                                          &actual_type_ret,
151
162
        if (return_code != Success || actual_format_ret == 0 || nitems == 0) {
152
163
            if (return_code == Success)
153
164
                XFree (prop);
 
165
            client->property_offset = 0;
154
166
            return (unsigned char *) NULL;
155
167
        }
156
 
        if (length != nitems)
157
 
            length = nitems;
158
 
        if (actual_format_ret == 16)
159
 
            length *= 2;
160
 
        else if (actual_format_ret == 32)
161
 
            length *= 4;
162
 
 
 
168
        /* Update the offset to read next time as needed */
 
169
        if (bytes_after_ret > 0)
 
170
                client->property_offset += length;
 
171
        else
 
172
                client->property_offset = 0;
 
173
        switch (actual_format_ret) {
 
174
            case 8:
 
175
            case 16:
 
176
            case 32:
 
177
                    length = nitems * actual_format_ret / 8;
 
178
                    break;
 
179
            default:
 
180
                    fprintf(stderr, "%s: unknown property return format: %d\n",
 
181
                            __FUNCTION__, actual_format_ret);
 
182
                    XFree(prop);
 
183
                    client->property_offset = 0;
 
184
                    return NULL;
 
185
        }
163
186
        /* if hit, it might be an error */
164
187
        if ((p = (unsigned char *) malloc (length)) == NULL)
165
188
            return (unsigned char *) NULL;