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>master
parent
7a87c202b7
commit
a931740cc7
|
@ -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) {
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -44,6 +44,7 @@ main(void)
|
|||
assert(test_file(ctx, "keymaps/comprehensive-plus-geom.xkb"));
|
||||
assert(test_file(ctx, "keymaps/no-types.xkb"));
|
||||
assert(test_file(ctx, "keymaps/quartz.xkb"));
|
||||
assert(test_file(ctx, "keymaps/no-aliases.xkb"));
|
||||
|
||||
assert(!test_file(ctx, "keymaps/divide-by-zero.xkb"));
|
||||
assert(!test_file(ctx, "keymaps/bad.xkb"));
|
||||
|
|
Loading…
Reference in New Issue