xkbcomp: Atom text and expr leak fixes part #973

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
master
Daniel Stone 2010-06-15 15:25:40 +01:00
parent a22386d402
commit 18039a6c0b
2 changed files with 52 additions and 32 deletions

View File

@ -324,7 +324,7 @@ AddKeyType(XkbcDescPtr xkb, KeyTypesInfo * info, KeyTypeInfo * new)
&& (warningLevel > 0)) || (warningLevel > 9)) && (warningLevel > 0)) || (warningLevel > 9))
{ {
WARN("Multiple definitions of the %s key type\n", WARN("Multiple definitions of the %s key type\n",
XkbcAtomGetString(new->name)); XkbcAtomText(new->name));
ACTION("Earlier definition ignored\n"); ACTION("Earlier definition ignored\n");
} }
FreeKeyTypeInfo(old); FreeKeyTypeInfo(old);
@ -340,7 +340,7 @@ AddKeyType(XkbcDescPtr xkb, KeyTypesInfo * info, KeyTypeInfo * new)
if (report) if (report)
{ {
WARN("Multiple definitions of the %s key type\n", WARN("Multiple definitions of the %s key type\n",
XkbcAtomGetString(new->name)); XkbcAtomText(new->name));
ACTION("Later definition ignored\n"); ACTION("Later definition ignored\n");
} }
FreeKeyTypeInfo(new); FreeKeyTypeInfo(new);
@ -837,6 +837,7 @@ SetLevelName(KeyTypeInfo * type, ExprDef * arrayNdx, ExprDef * value)
{ {
ExprResult rtrn; ExprResult rtrn;
unsigned level; unsigned level;
Atom level_name;
if (arrayNdx == NULL) if (arrayNdx == NULL)
return ReportTypeShouldBeArray(type, "level name"); return ReportTypeShouldBeArray(type, "level name");
@ -859,9 +860,9 @@ SetLevelName(KeyTypeInfo * type, ExprDef * arrayNdx, ExprDef * value)
ACTION("Ignoring illegal level name definition\n"); ACTION("Ignoring illegal level name definition\n");
return False; return False;
} }
return level_name = XkbcInternAtom(rtrn.str, False);
AddLevelName(type, level, XkbcInternAtom(rtrn.str, False), True, free(rtrn.str);
True); return AddLevelName(type, level, level_name, True, True);
} }
/***====================================================================***/ /***====================================================================***/

View File

@ -1144,6 +1144,7 @@ SetSymbolsField(KeyInfo * key,
ERROR("Illegal group index for type of key %s\n", ERROR("Illegal group index for type of key %s\n",
longText(key->name)); longText(key->name));
ACTION("Definition with non-integer array index ignored\n"); ACTION("Definition with non-integer array index ignored\n");
free(tmp.str);
return False; return False;
} }
else if ((ndx.uval < 1) || (ndx.uval > XkbNumKbdGroups)) else if ((ndx.uval < 1) || (ndx.uval > XkbNumKbdGroups))
@ -1152,6 +1153,7 @@ SetSymbolsField(KeyInfo * key,
("Group index for type of key %s is out of range (1..%d)\n", ("Group index for type of key %s is out of range (1..%d)\n",
longText(key->name), XkbNumKbdGroups + 1); longText(key->name), XkbNumKbdGroups + 1);
ACTION("Ignoring type for group %d\n", ndx.uval); ACTION("Ignoring type for group %d\n", ndx.uval);
free(tmp.str);
return False; return False;
} }
else else
@ -1159,6 +1161,7 @@ SetSymbolsField(KeyInfo * key,
key->types[ndx.uval - 1] = XkbcInternAtom(tmp.str, False); key->types[ndx.uval - 1] = XkbcInternAtom(tmp.str, False);
key->typesDefined |= (1 << (ndx.uval - 1)); key->typesDefined |= (1 << (ndx.uval - 1));
} }
free(tmp.str);
} }
else if (uStrCaseCmp(field, "symbols") == 0) else if (uStrCaseCmp(field, "symbols") == 0)
return AddSymbolsToKey(key, xkb, field, arrayNdx, value, info); return AddSymbolsToKey(key, xkb, field, arrayNdx, value, info);
@ -1407,19 +1410,20 @@ HandleSymbolsVar(VarDef * stmt, XkbcDescPtr xkb, SymbolsInfo * info)
{ {
ExprResult elem, field, tmp; ExprResult elem, field, tmp;
ExprDef *arrayNdx; ExprDef *arrayNdx;
Bool ret;
if (ExprResolveLhs(stmt->name, &elem, &field, &arrayNdx) == 0) if (ExprResolveLhs(stmt->name, &elem, &field, &arrayNdx) == 0)
return 0; /* internal error, already reported */ return 0; /* internal error, already reported */
if (elem.str && (uStrCaseCmp(elem.str, "key") == 0)) if (elem.str && (uStrCaseCmp(elem.str, "key") == 0))
{ {
return SetSymbolsField(&info->dflt, xkb, field.str, arrayNdx, ret = SetSymbolsField(&info->dflt, xkb, field.str, arrayNdx,
stmt->value, info); stmt->value, info);
} }
else if ((elem.str == NULL) && ((uStrCaseCmp(field.str, "name") == 0) || else if ((elem.str == NULL) && ((uStrCaseCmp(field.str, "name") == 0) ||
(uStrCaseCmp(field.str, "groupname") == (uStrCaseCmp(field.str, "groupname") ==
0))) 0)))
{ {
return SetGroupName(info, arrayNdx, stmt->value); ret = SetGroupName(info, arrayNdx, stmt->value);
} }
else if ((elem.str == NULL) else if ((elem.str == NULL)
&& ((uStrCaseCmp(field.str, "groupswrap") == 0) && ((uStrCaseCmp(field.str, "groupswrap") == 0)
@ -1429,13 +1433,15 @@ HandleSymbolsVar(VarDef * stmt, XkbcDescPtr xkb, SymbolsInfo * info)
{ {
ERROR("Illegal setting for global groupsWrap\n"); ERROR("Illegal setting for global groupsWrap\n");
ACTION("Non-boolean value ignored\n"); ACTION("Non-boolean value ignored\n");
return False; ret = False;
}
else {
if (tmp.uval)
info->groupInfo = XkbWrapIntoRange;
else
info->groupInfo = XkbClampIntoRange;
ret = True;
} }
if (tmp.uval)
info->groupInfo = XkbWrapIntoRange;
else
info->groupInfo = XkbClampIntoRange;
return True;
} }
else if ((elem.str == NULL) else if ((elem.str == NULL)
&& ((uStrCaseCmp(field.str, "groupsclamp") == 0) && ((uStrCaseCmp(field.str, "groupsclamp") == 0)
@ -1447,11 +1453,13 @@ HandleSymbolsVar(VarDef * stmt, XkbcDescPtr xkb, SymbolsInfo * info)
ACTION("Non-boolean value ignored\n"); ACTION("Non-boolean value ignored\n");
return False; return False;
} }
if (tmp.uval) else {
info->groupInfo = XkbClampIntoRange; if (tmp.uval)
else info->groupInfo = XkbClampIntoRange;
info->groupInfo = XkbWrapIntoRange; else
return True; info->groupInfo = XkbWrapIntoRange;
ret = True;
}
} }
else if ((elem.str == NULL) else if ((elem.str == NULL)
&& ((uStrCaseCmp(field.str, "groupsredirect") == 0) && ((uStrCaseCmp(field.str, "groupsredirect") == 0)
@ -1462,25 +1470,36 @@ HandleSymbolsVar(VarDef * stmt, XkbcDescPtr xkb, SymbolsInfo * info)
{ {
ERROR("Illegal group index for global groupsRedirect\n"); ERROR("Illegal group index for global groupsRedirect\n");
ACTION("Definition with non-integer group ignored\n"); ACTION("Definition with non-integer group ignored\n");
return False; ret = False;
} }
if ((tmp.uval < 1) || (tmp.uval > XkbNumKbdGroups)) else {
{ if ((tmp.uval < 1) || (tmp.uval > XkbNumKbdGroups))
ERROR {
("Out-of-range (1..%d) group for global groupsRedirect\n", ERROR
XkbNumKbdGroups); ("Out-of-range (1..%d) group for global groupsRedirect\n",
ACTION("Ignoring illegal group %d\n", tmp.uval); XkbNumKbdGroups);
return False; ACTION("Ignoring illegal group %d\n", tmp.uval);
ret = False;
}
else {
info->groupInfo = XkbSetGroupInfo(0, XkbRedirectIntoRange,
tmp.uval);
ret = True;
}
} }
info->groupInfo = XkbSetGroupInfo(0, XkbRedirectIntoRange, tmp.uval);
return True;
} }
else if ((elem.str == NULL) && (uStrCaseCmp(field.str, "allownone") == 0)) else if ((elem.str == NULL) && (uStrCaseCmp(field.str, "allownone") == 0))
{ {
return SetAllowNone(&info->dflt, arrayNdx, stmt->value); ret = SetAllowNone(&info->dflt, arrayNdx, stmt->value);
} }
return SetActionField(xkb, elem.str, field.str, arrayNdx, stmt->value, else {
&info->action); ret = SetActionField(xkb, elem.str, field.str, arrayNdx, stmt->value,
&info->action);
}
free(elem.str);
free(field.str);
return ret;
} }
static Bool static Bool