xkbcomp: Don't leak atom text and string exprs 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
diff --git a/src/xkbcomp/action.c b/src/xkbcomp/action.c
index 6d55d68..3f0953d 100644
--- a/src/xkbcomp/action.c
+++ b/src/xkbcomp/action.c
@@ -373,7 +373,7 @@ CheckModifierField(XkbcDescPtr xkb,
if (value->op == ExprIdent)
{
register char *valStr;
- valStr = XkbcAtomGetString(value->value.str);
+ valStr = XkbcAtomText(value->value.str);
if (valStr && ((uStrCaseCmp(valStr, "usemodmapmods") == 0) ||
(uStrCaseCmp(valStr, "modmapmods") == 0)))
{
@@ -1202,6 +1202,7 @@ HandlePrivate(XkbcDescPtr xkb,
}
strncpy((char *) action->data, rtrn.str, 7);
}
+ free(rtrn.str);
return True;
}
else
@@ -1368,13 +1369,19 @@ HandleActionDef(ExprDef * def,
ERROR("Cannot change defaults in an action definition\n");
ACTION("Ignoring attempt to change %s.%s\n", elemRtrn.str,
fieldRtrn.str);
+ free(elemRtrn.str);
+ free(fieldRtrn.str);
return False;
}
if (!stringToField(fieldRtrn.str, &fieldNdx))
{
ERROR("Unknown field name %s\n", uStringText(fieldRtrn.str));
+ free(elemRtrn.str);
+ free(fieldRtrn.str);
return False;
}
+ free(elemRtrn.str);
+ free(fieldRtrn.str);
if (!(*handleAction[hndlrType])
(xkb, action, fieldNdx, arrayRtrn, value))
{
@@ -1408,17 +1415,22 @@ SetActionField(XkbcDescPtr xkb,
else
{
if (!stringToAction(elem, &new->action))
+ {
+ free(new);
return False;
+ }
if (new->action == XkbSA_NoAction)
{
ERROR("\"%s\" is not a valid field in a NoAction action\n",
field);
+ free(new);
return False;
}
}
if (!stringToField(field, &new->field))
{
ERROR("\"%s\" is not a legal field name\n", field);
+ free(new);
return False;
}
new->array_ndx = array_ndx;
diff --git a/src/xkbcomp/compat.c b/src/xkbcomp/compat.c
index 1e518cf..461c759 100644
--- a/src/xkbcomp/compat.c
+++ b/src/xkbcomp/compat.c
@@ -608,19 +608,22 @@ HandleInterpVar(VarDef * stmt, XkbcDescPtr xkb, CompatInfo * info)
{
ExprResult elem, field;
ExprDef *ndx;
+ int ret;
if (ExprResolveLhs(stmt->name, &elem, &field, &ndx) == 0)
- return 0; /* internal error, already reported */
- if (elem.str && (uStrCaseCmp(elem.str, "interpret") == 0))
- return SetInterpField(&info->dflt, xkb, field.str, ndx, stmt->value,
+ ret = 0; /* internal error, already reported */
+ else if (elem.str && (uStrCaseCmp(elem.str, "interpret") == 0))
+ ret = SetInterpField(&info->dflt, xkb, field.str, ndx, stmt->value,
info);
- if (elem.str && (uStrCaseCmp(elem.str, "indicator") == 0))
- {
- return SetIndicatorMapField(&info->ledDflt, xkb, field.str, ndx,
- stmt->value);
- }
- return SetActionField(xkb, elem.str, field.str, ndx, stmt->value,
- &info->act);
+ else if (elem.str && (uStrCaseCmp(elem.str, "indicator") == 0))
+ ret = SetIndicatorMapField(&info->ledDflt, xkb, field.str, ndx,
+ stmt->value);
+ else
+ ret = SetActionField(xkb, elem.str, field.str, ndx, stmt->value,
+ &info->act);
+ free(elem.str);
+ free(field.str);
+ return ret;
}
static int