summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjeon <jhyuni.kang@samsung.com>2019-11-05 18:52:25 +0900
committerJihoon Kim <jihoon48.kim@samsung.com>2023-12-22 08:43:48 +0900
commit09cef9ece135ff9e1d677704856b60f90a6b0b71 (patch)
treee3d1401dc8b1c47cb3a26dbbb55df88ad30f7d6b
parent5e58c8151ec7b74ca17fc7018ba084893bc0ebbc (diff)
downloadlibxkbcommon-09cef9ece135ff9e1d677704856b60f90a6b0b71.tar.gz
libxkbcommon-09cef9ece135ff9e1d677704856b60f90a6b0b71.tar.bz2
libxkbcommon-09cef9ece135ff9e1d677704856b60f90a6b0b71.zip
xkbcomp: add null checkers after calloc()
Change-Id: Ie5f050d20a678260f00778de20aad830c5b3208b
-rw-r--r--src/xkbcomp/symbols.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/xkbcomp/symbols.c b/src/xkbcomp/symbols.c
index 20eebeb..6d46884 100644
--- a/src/xkbcomp/symbols.c
+++ b/src/xkbcomp/symbols.c
@@ -715,8 +715,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,
@@ -1491,6 +1496,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) {