diff options
author | Adam Tkac <atkac@redhat.com> | 2010-08-25 10:38:40 +0200 |
---|---|---|
committer | Jeremy Huddleston <jeremyhu@apple.com> | 2010-12-03 13:21:34 -0800 |
commit | 2fa0029b54a6a27ec4cb3fa1239a8f7fd582b562 (patch) | |
tree | 2f224e378bb2a2a32904047156420ea9700f5f5e | |
parent | 806790bd9194b60419281442b1ae4fc5fff802aa (diff) |
Return Success from generate_modkeymap() when max_keys_per_mod is zero
max_keys_per_mod equal to zero is a valid situation so generate_modkeymap
should not return BadAlloc in this case.
Signed-off-by: Adam Tkac <atkac@redhat.com>
Reviewed-by: Patrick E. Kane <pekane52 at gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit 05e616767e5b7e60b92d31c4042ded5892dce6d4)
-rw-r--r-- | dix/inpututils.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/dix/inpututils.c b/dix/inpututils.c index 8ec80b5e8..6693c67b3 100644 --- a/dix/inpututils.c +++ b/dix/inpututils.c @@ -286,7 +286,7 @@ int generate_modkeymap(ClientPtr client, DeviceIntPtr dev, { CARD8 keys_per_mod[8]; int max_keys_per_mod; - KeyCode *modkeymap; + KeyCode *modkeymap = NULL; int i, j, ret; ret = XaceHook(XACE_DEVICE_ACCESS, client, dev, DixGetAttrAccess); @@ -310,18 +310,20 @@ int generate_modkeymap(ClientPtr client, DeviceIntPtr dev, } } - modkeymap = calloc(max_keys_per_mod * 8, sizeof(KeyCode)); - if (!modkeymap) - return BadAlloc; + if (max_keys_per_mod != 0) { + modkeymap = calloc(max_keys_per_mod * 8, sizeof(KeyCode)); + if (!modkeymap) + return BadAlloc; - for (i = 0; i < 8; i++) - keys_per_mod[i] = 0; + for (i = 0; i < 8; i++) + keys_per_mod[i] = 0; - for (i = 8; i < MAP_LENGTH; i++) { - for (j = 0; j < 8; j++) { - if (dev->key->xkbInfo->desc->map->modmap[i] & (1 << j)) { - modkeymap[(j * max_keys_per_mod) + keys_per_mod[j]] = i; - keys_per_mod[j]++; + for (i = 8; i < MAP_LENGTH; i++) { + for (j = 0; j < 8; j++) { + if (dev->key->xkbInfo->desc->map->modmap[i] & (1 << j)) { + modkeymap[(j * max_keys_per_mod) + keys_per_mod[j]] = i; + keys_per_mod[j]++; + } } } } |