Imported Debian patch 2:1.15.1-0ubuntu2.6
[deb_xorg-server.git] / debian / patches / xi2-resize-touch.patch
1 diff --git a/dix/touch.c b/dix/touch.c
2 index a7ea213..1478e38 100644
3 --- a/dix/touch.c
4 +++ b/dix/touch.c
5 @@ -460,12 +460,26 @@ TouchEventHistoryPush(TouchPointInfoPtr ti, const DeviceEvent *ev)
6 if (ev->flags & (TOUCH_CLIENT_ID | TOUCH_REPLAYING))
7 return;
8
9 + if (ti->history_elements == ti->history_size - 1) {
10 + DeviceEvent *hist = NULL;
11 + size_t sz = ti->history_size * 2;
12 +
13 + if (sz < 10000) {
14 + hist = realloc(ti->history, sz * sizeof(*hist));
15 +
16 + if (hist) {
17 + ti->history = hist;
18 + ti->history_size = sz;
19 + memset(&hist[sz/2], 0, sizeof(*hist)*sz/2);
20 + }
21 + }
22 + }
23 +
24 ti->history[ti->history_elements++] = *ev;
25 - /* FIXME: proper overflow fixes */
26 if (ti->history_elements > ti->history_size - 1) {
27 ti->history_elements = ti->history_size - 1;
28 - DebugF("source device %d: history size %d overflowing for touch %u\n",
29 - ti->sourceid, ti->history_size, ti->client_id);
30 + ErrorF("source device %d: history size %d overflowing for touch %u\n",
31 + ti->sourceid, ti->history_size, ti->client_id);
32 }
33 }
34