summaryrefslogtreecommitdiff
path: root/src/xkbcomp/keycodes.c
diff options
context:
space:
mode:
authorRan Benita <ran234@gmail.com>2014-09-10 13:29:52 +0300
committerRan Benita <ran234@gmail.com>2014-09-10 13:44:33 +0300
commita931740cc70eff217ddf20492c6f500ac9f991e4 (patch)
tree02624f9c0b5e6e5c2109fc47f253a4c887582116 /src/xkbcomp/keycodes.c
parent7a87c202b70d6b0b5b5cedea5d49ace3c4c15535 (diff)
downloadlibxkbcommon-a931740cc70eff217ddf20492c6f500ac9f991e4.tar.gz
libxkbcommon-a931740cc70eff217ddf20492c6f500ac9f991e4.tar.bz2
libxkbcommon-a931740cc70eff217ddf20492c6f500ac9f991e4.zip
keycodes: fix keymap compilation with no aliases and malloc(0)==NULL
If the keymap doesn't have any key-aliases (which is certainly possible), the calloc(num_key_aliases, ...) is allowed to return NULL according to the C standard, but this is not an error. Signed-off-by: Ran Benita <ran234@gmail.com>
Diffstat (limited to 'src/xkbcomp/keycodes.c')
-rw-r--r--src/xkbcomp/keycodes.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/xkbcomp/keycodes.c b/src/xkbcomp/keycodes.c
index fdddb7a..6200cea 100644
--- a/src/xkbcomp/keycodes.c
+++ b/src/xkbcomp/keycodes.c
@@ -591,9 +591,12 @@ CopyKeyAliasesToKeymap(struct xkb_keymap *keymap, KeyNamesInfo *info)
}
/* Copy key aliases. */
- key_aliases = calloc(num_key_aliases, sizeof(*key_aliases));
- if (!key_aliases)
- return false;
+ key_aliases = NULL;
+ if (num_key_aliases > 0) {
+ key_aliases = calloc(num_key_aliases, sizeof(*key_aliases));
+ if (!key_aliases)
+ return false;
+ }
i = 0;
darray_foreach(alias, info->aliases) {