From 29591363f86e5e0e7c3b3c058c0f77970b1e6680 Mon Sep 17 00:00:00 2001 From: Diego Nieto Cid Date: Sat, 21 Aug 2010 03:07:38 -0300 Subject: Fix memory errors. * console-client/xkb/parser.y (key_set_keysym): Consider symbol's size when reallocing. (key_set_action): Consider (xkb_action_t *)'s size when reallocing. Start clearing levels from 'width' and up to 'level'. --- console-client/xkb/parser.y | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'console-client/xkb') diff --git a/console-client/xkb/parser.y b/console-client/xkb/parser.y index 66134f89..854ee408 100644 --- a/console-client/xkb/parser.y +++ b/console-client/xkb/parser.y @@ -1377,7 +1377,7 @@ key_set_keysym (struct key *key, group_t group, int level, symbol ks) if ((level + 1) > key->groups[group].width) { - keysyms = realloc (keysyms, level + 1); + keysyms = realloc (keysyms, (level + 1)*sizeof(symbol)); if (!keys) { @@ -1408,9 +1408,9 @@ key_set_action (struct key *key, group_t group, int level, xkb_action_t *action) if ((size_t) (level + 1) > width) { - actions = realloc (actions, level + 1); - /* Previous levels have no actions defined. */ - memset (&actions[level - 1], 0, level - width); + actions = realloc (actions, (level + 1)*sizeof(xkb_action_t *)); + /* Levels between 'width' and 'level' have no actions defined. */ + memset (&actions[width], 0, (level - width)*sizeof(xkb_action_t *)); if (!keys) { -- cgit v1.2.3