Pass merge down through indicator creation

To avoid using potentially undefined memory.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
master
Daniel Stone 2012-05-29 16:12:54 +01:00
parent 243daf80d0
commit a3ae0e84e4
1 changed files with 7 additions and 7 deletions

View File

@ -156,14 +156,13 @@ FindIndicatorByName(KeyNamesInfo * info, xkb_atom_t name)
} }
static bool static bool
AddIndicatorName(KeyNamesInfo *info, struct xkb_keymap *keymap, AddIndicatorName(KeyNamesInfo *info, struct xkb_keymap *keymap, unsigned merge,
IndicatorNameInfo *new) IndicatorNameInfo *new)
{ {
IndicatorNameInfo *old; IndicatorNameInfo *old;
bool replace; bool replace;
replace = (new->defs.merge == MergeReplace) || replace = (merge == MergeReplace) || (merge == MergeOverride);
(new->defs.merge == MergeOverride);
old = FindIndicatorByName(info, new->name); old = FindIndicatorByName(info, new->name);
if (old) if (old)
{ {
@ -463,7 +462,7 @@ MergeIncludedKeycodes(KeyNamesInfo *into, struct xkb_keymap *keymap,
{ {
if (merge != MergeDefault) if (merge != MergeDefault)
led->defs.merge = merge; led->defs.merge = merge;
if (!AddIndicatorName(into, keymap, led)) if (!AddIndicatorName(into, keymap, led->defs.merge, led))
into->errorCount++; into->errorCount++;
next = (IndicatorNameInfo *) led->defs.next; next = (IndicatorNameInfo *) led->defs.next;
} }
@ -708,7 +707,7 @@ err_out:
static int static int
HandleIndicatorNameDef(IndicatorNameDef *def, struct xkb_keymap *keymap, HandleIndicatorNameDef(IndicatorNameDef *def, struct xkb_keymap *keymap,
KeyNamesInfo *info) unsigned merge, KeyNamesInfo *info)
{ {
IndicatorNameInfo ii; IndicatorNameInfo ii;
ExprResult tmp; ExprResult tmp;
@ -732,7 +731,7 @@ HandleIndicatorNameDef(IndicatorNameDef *def, struct xkb_keymap *keymap,
ii.name = xkb_atom_intern(keymap->ctx, tmp.str); ii.name = xkb_atom_intern(keymap->ctx, tmp.str);
free(tmp.str); free(tmp.str);
ii.virtual = def->virtual; ii.virtual = def->virtual;
if (!AddIndicatorName(info, keymap, &ii)) if (!AddIndicatorName(info, keymap, merge, &ii))
return false; return false;
return true; return true;
} }
@ -781,7 +780,8 @@ HandleKeycodesFile(XkbFile *file, struct xkb_keymap *keymap,
info->errorCount++; info->errorCount++;
break; break;
case StmtIndicatorNameDef: /* e.g. indicator 1 = "Caps Lock"; */ case StmtIndicatorNameDef: /* e.g. indicator 1 = "Caps Lock"; */
if (!HandleIndicatorNameDef((IndicatorNameDef *) stmt, keymap, info)) if (!HandleIndicatorNameDef((IndicatorNameDef *) stmt, keymap,
merge, info))
info->errorCount++; info->errorCount++;
break; break;
case StmtInterpDef: case StmtInterpDef: