Pass merge down through indicator creation To avoid using potentially undefined memory. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
diff --git a/src/xkbcomp/keycodes.c b/src/xkbcomp/keycodes.c
index 3a2208c..80f80ee 100644
--- a/src/xkbcomp/keycodes.c
+++ b/src/xkbcomp/keycodes.c
@@ -156,14 +156,13 @@ FindIndicatorByName(KeyNamesInfo * info, xkb_atom_t name)
}
static bool
-AddIndicatorName(KeyNamesInfo *info, struct xkb_keymap *keymap,
+AddIndicatorName(KeyNamesInfo *info, struct xkb_keymap *keymap, unsigned merge,
IndicatorNameInfo *new)
{
IndicatorNameInfo *old;
bool replace;
- replace = (new->defs.merge == MergeReplace) ||
- (new->defs.merge == MergeOverride);
+ replace = (merge == MergeReplace) || (merge == MergeOverride);
old = FindIndicatorByName(info, new->name);
if (old)
{
@@ -463,7 +462,7 @@ MergeIncludedKeycodes(KeyNamesInfo *into, struct xkb_keymap *keymap,
{
if (merge != MergeDefault)
led->defs.merge = merge;
- if (!AddIndicatorName(into, keymap, led))
+ if (!AddIndicatorName(into, keymap, led->defs.merge, led))
into->errorCount++;
next = (IndicatorNameInfo *) led->defs.next;
}
@@ -708,7 +707,7 @@ err_out:
static int
HandleIndicatorNameDef(IndicatorNameDef *def, struct xkb_keymap *keymap,
- KeyNamesInfo *info)
+ unsigned merge, KeyNamesInfo *info)
{
IndicatorNameInfo ii;
ExprResult tmp;
@@ -732,7 +731,7 @@ HandleIndicatorNameDef(IndicatorNameDef *def, struct xkb_keymap *keymap,
ii.name = xkb_atom_intern(keymap->ctx, tmp.str);
free(tmp.str);
ii.virtual = def->virtual;
- if (!AddIndicatorName(info, keymap, &ii))
+ if (!AddIndicatorName(info, keymap, merge, &ii))
return false;
return true;
}
@@ -781,7 +780,8 @@ HandleKeycodesFile(XkbFile *file, struct xkb_keymap *keymap,
info->errorCount++;
break;
case StmtIndicatorNameDef: /* e.g. indicator 1 = "Caps Lock"; */
- if (!HandleIndicatorNameDef((IndicatorNameDef *) stmt, keymap, info))
+ if (!HandleIndicatorNameDef((IndicatorNameDef *) stmt, keymap,
+ merge, info))
info->errorCount++;
break;
case StmtInterpDef: