diff options
author | jeon <jhyuni.kang@samsung.com> | 2019-11-05 18:52:25 +0900 |
---|---|---|
committer | Duna Oh <duna.oh@samsung.com> | 2022-02-07 14:50:11 +0900 |
commit | cc63cf3d13de04e24c2c42dc667b515e687b0432 (patch) | |
tree | 48555ef31623bb978ec085cf5afee19a0986738d | |
parent | dc3149e2c9a42a1b500601228a594402cafacb97 (diff) | |
download | libxkbcommon-cc63cf3d13de04e24c2c42dc667b515e687b0432.tar.gz libxkbcommon-cc63cf3d13de04e24c2c42dc667b515e687b0432.tar.bz2 libxkbcommon-cc63cf3d13de04e24c2c42dc667b515e687b0432.zip |
xkbcomp: add null checkers after calloc()
Change-Id: Ie5f050d20a678260f00778de20aad830c5b3208b
-rw-r--r-- | src/xkbcomp/symbols.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/xkbcomp/symbols.c b/src/xkbcomp/symbols.c index eb78412..c2cd6e0 100644 --- a/src/xkbcomp/symbols.c +++ b/src/xkbcomp/symbols.c @@ -698,8 +698,13 @@ AddSymbolsToKey(SymbolsInfo *info, KeyInfo *keyi, ExprDef *arrayNdx, sym_index = darray_item(value->keysym_list.symsMapIndex, i); leveli->num_syms = darray_item(value->keysym_list.symsNumEntries, i); - if (leveli->num_syms > 1) + if (leveli->num_syms > 1) { leveli->u.syms = calloc(leveli->num_syms, sizeof(*leveli->u.syms)); + if (!leveli->u.syms) { + log_err(info->ctx, "Failed to allocate memory for leveli->u.syms\n"); + continue; + } + } for (unsigned j = 0; j < leveli->num_syms; j++) { xkb_keysym_t keysym = darray_item(value->keysym_list.syms, @@ -1439,6 +1444,10 @@ CopySymbolsDefToKeymap(struct xkb_keymap *keymap, SymbolsInfo *info, } key->groups = calloc(key->num_groups, sizeof(*key->groups)); + if (!key->groups) { + log_err(info->ctx, "Failed to allocate memory for key->groups\n"); + return false; + } /* Find and assign the groups' types in the keymap. */ darray_enumerate(i, groupi, keyi->groups) { |