Port D1089 patch from Seunghun Lee <shiin.lee@samsung.com> to current

E master

fix crash and memory leak when press and release any key repeatedly.

Summary:
since the size of wl_array is determined based on one byte,
so in order to compare with uint32_t, the size of wl_array should
be divided by uint32_t's size.
and when calculate the size of wl_array by difference between two
address, address should type cast char* as one byte.

Test Plan:
(1) run terminology
(2) input any key several time.

Signed-off-by: Chris Michael <cp.michael@samsung.com>
This commit is contained in:
Chris Michael 2014-06-26 10:58:06 -04:00
parent 12d22d8fc8
commit f6d2f30d93
1 changed files with 4 additions and 4 deletions

View File

@ -1350,11 +1350,11 @@ _e_wl_shell_shell_surface_cb_key_up(void *data, Evas *e EINA_UNUSED, Evas_Object
sym = xkb_keysym_from_name(ev->key, XKB_KEYSYM_CASE_INSENSITIVE);
key = sym - 8;
}
end = ((unsigned int *)kbd->keys.data + kbd->keys.size);
end = ((unsigned int *)kbd->keys.data + (kbd->keys.size / sizeof(*k)));
for (k = kbd->keys.data; k < end; k++)
if ((*k == key)) *k = *--end;
kbd->keys.size = end - (unsigned int *)kbd->keys.data;
kbd->keys.size = (const char *)end - (const char *)kbd->keys.data;
/* try to get the current keyboard's grab interface.
* Fallback to the default grab */
@ -1425,14 +1425,14 @@ _e_wl_shell_shell_surface_cb_key_down(void *data, Evas *e EINA_UNUSED, Evas_Obje
kbd->grab_key = key;
kbd->grab_time = ev->timestamp;
end = ((unsigned int *)kbd->keys.data + kbd->keys.size);
end = ((unsigned int *)kbd->keys.data + (kbd->keys.size / sizeof(*k)));
for (k = kbd->keys.data; k < end; k++)
{
/* ignore server generated key repeats */
if ((*k == key)) return;
}
kbd->keys.size = end - (unsigned int *)kbd->keys.data;
kbd->keys.size = (const char *)end - (const char *)kbd->keys.data;
k = wl_array_add(&kbd->keys, sizeof(*k));
*k = key;