xkbcomp: Atom text and expr leak fixes part #973 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 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186
diff --git a/src/xkbcomp/keytypes.c b/src/xkbcomp/keytypes.c
index bb77811..b15fc3e 100644
--- a/src/xkbcomp/keytypes.c
+++ b/src/xkbcomp/keytypes.c
@@ -324,7 +324,7 @@ AddKeyType(XkbcDescPtr xkb, KeyTypesInfo * info, KeyTypeInfo * new)
&& (warningLevel > 0)) || (warningLevel > 9))
{
WARN("Multiple definitions of the %s key type\n",
- XkbcAtomGetString(new->name));
+ XkbcAtomText(new->name));
ACTION("Earlier definition ignored\n");
}
FreeKeyTypeInfo(old);
@@ -340,7 +340,7 @@ AddKeyType(XkbcDescPtr xkb, KeyTypesInfo * info, KeyTypeInfo * new)
if (report)
{
WARN("Multiple definitions of the %s key type\n",
- XkbcAtomGetString(new->name));
+ XkbcAtomText(new->name));
ACTION("Later definition ignored\n");
}
FreeKeyTypeInfo(new);
@@ -837,6 +837,7 @@ SetLevelName(KeyTypeInfo * type, ExprDef * arrayNdx, ExprDef * value)
{
ExprResult rtrn;
unsigned level;
+ Atom level_name;
if (arrayNdx == NULL)
return ReportTypeShouldBeArray(type, "level name");
@@ -859,9 +860,9 @@ SetLevelName(KeyTypeInfo * type, ExprDef * arrayNdx, ExprDef * value)
ACTION("Ignoring illegal level name definition\n");
return False;
}
- return
- AddLevelName(type, level, XkbcInternAtom(rtrn.str, False), True,
- True);
+ level_name = XkbcInternAtom(rtrn.str, False);
+ free(rtrn.str);
+ return AddLevelName(type, level, level_name, True, True);
}
/***====================================================================***/
diff --git a/src/xkbcomp/symbols.c b/src/xkbcomp/symbols.c
index fedaf01..efc6555 100644
--- a/src/xkbcomp/symbols.c
+++ b/src/xkbcomp/symbols.c
@@ -1144,6 +1144,7 @@ SetSymbolsField(KeyInfo * key,
ERROR("Illegal group index for type of key %s\n",
longText(key->name));
ACTION("Definition with non-integer array index ignored\n");
+ free(tmp.str);
return False;
}
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",
longText(key->name), XkbNumKbdGroups + 1);
ACTION("Ignoring type for group %d\n", ndx.uval);
+ free(tmp.str);
return False;
}
else
@@ -1159,6 +1161,7 @@ SetSymbolsField(KeyInfo * key,
key->types[ndx.uval - 1] = XkbcInternAtom(tmp.str, False);
key->typesDefined |= (1 << (ndx.uval - 1));
}
+ free(tmp.str);
}
else if (uStrCaseCmp(field, "symbols") == 0)
return AddSymbolsToKey(key, xkb, field, arrayNdx, value, info);
@@ -1407,19 +1410,20 @@ HandleSymbolsVar(VarDef * stmt, XkbcDescPtr xkb, SymbolsInfo * info)
{
ExprResult elem, field, tmp;
ExprDef *arrayNdx;
+ Bool ret;
if (ExprResolveLhs(stmt->name, &elem, &field, &arrayNdx) == 0)
return 0; /* internal error, already reported */
if (elem.str && (uStrCaseCmp(elem.str, "key") == 0))
{
- return SetSymbolsField(&info->dflt, xkb, field.str, arrayNdx,
- stmt->value, info);
+ ret = SetSymbolsField(&info->dflt, xkb, field.str, arrayNdx,
+ stmt->value, info);
}
else if ((elem.str == NULL) && ((uStrCaseCmp(field.str, "name") == 0) ||
(uStrCaseCmp(field.str, "groupname") ==
0)))
{
- return SetGroupName(info, arrayNdx, stmt->value);
+ ret = SetGroupName(info, arrayNdx, stmt->value);
}
else if ((elem.str == NULL)
&& ((uStrCaseCmp(field.str, "groupswrap") == 0)
@@ -1429,13 +1433,15 @@ HandleSymbolsVar(VarDef * stmt, XkbcDescPtr xkb, SymbolsInfo * info)
{
ERROR("Illegal setting for global groupsWrap\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)
&& ((uStrCaseCmp(field.str, "groupsclamp") == 0)
@@ -1447,11 +1453,13 @@ HandleSymbolsVar(VarDef * stmt, XkbcDescPtr xkb, SymbolsInfo * info)
ACTION("Non-boolean value ignored\n");
return False;
}
- if (tmp.uval)
- info->groupInfo = XkbClampIntoRange;
- else
- info->groupInfo = XkbWrapIntoRange;
- return True;
+ else {
+ if (tmp.uval)
+ info->groupInfo = XkbClampIntoRange;
+ else
+ info->groupInfo = XkbWrapIntoRange;
+ ret = True;
+ }
}
else if ((elem.str == NULL)
&& ((uStrCaseCmp(field.str, "groupsredirect") == 0)
@@ -1462,25 +1470,36 @@ HandleSymbolsVar(VarDef * stmt, XkbcDescPtr xkb, SymbolsInfo * info)
{
ERROR("Illegal group index for global groupsRedirect\n");
ACTION("Definition with non-integer group ignored\n");
- return False;
+ ret = False;
}
- if ((tmp.uval < 1) || (tmp.uval > XkbNumKbdGroups))
- {
- ERROR
- ("Out-of-range (1..%d) group for global groupsRedirect\n",
- XkbNumKbdGroups);
- ACTION("Ignoring illegal group %d\n", tmp.uval);
- return False;
+ else {
+ if ((tmp.uval < 1) || (tmp.uval > XkbNumKbdGroups))
+ {
+ ERROR
+ ("Out-of-range (1..%d) group for global groupsRedirect\n",
+ XkbNumKbdGroups);
+ 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))
{
- return SetAllowNone(&info->dflt, arrayNdx, stmt->value);
+ ret = SetAllowNone(&info->dflt, arrayNdx, stmt->value);
}
- return SetActionField(xkb, elem.str, field.str, arrayNdx, stmt->value,
- &info->action);
+ else {
+ ret = SetActionField(xkb, elem.str, field.str, arrayNdx, stmt->value,
+ &info->action);
+ }
+
+ free(elem.str);
+ free(field.str);
+ return ret;
}
static Bool