summaryrefslogtreecommitdiff
path: root/console-client/xkb/parser.y
diff options
context:
space:
mode:
authorDiego Nieto Cid <dnietoc@gmail.com>2010-08-21 03:07:38 -0300
committerDiego Nieto Cid <dnietoc@gmail.com>2011-04-08 14:36:20 -0300
commit29591363f86e5e0e7c3b3c058c0f77970b1e6680 (patch)
tree0bc7b057d50d3eb0e0e34f5ee1b68b5050f50ab1 /console-client/xkb/parser.y
parenta4c3acc8ce65d27f6424557c43bf1d841db9401e (diff)
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'.
Diffstat (limited to 'console-client/xkb/parser.y')
-rw-r--r--console-client/xkb/parser.y8
1 files changed, 4 insertions, 4 deletions
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)
{