Still more memory leak fixes

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
master
Daniel Stone 2012-02-16 00:22:11 +00:00
parent 83f18b1c3a
commit c45cdb0c67
9 changed files with 43 additions and 11 deletions

View File

@ -279,6 +279,7 @@ static void
XkbcFreeControls(struct xkb_desc * xkb, unsigned which, Bool freeMap)
{
if (freeMap && xkb && xkb->ctrls) {
free(xkb->ctrls->per_key_repeat);
free(xkb->ctrls);
xkb->ctrls = NULL;
}

View File

@ -643,9 +643,11 @@ HandleInterpBody(VarDef * def, struct xkb_desc * xkb, SymInterpInfo * si,
continue;
}
ok = ExprResolveLhs(def->name, &tmp, &field, &arrayNdx);
if (ok)
if (ok) {
ok = SetInterpField(si, xkb, field.str, arrayNdx, def->value,
info);
free(field.str);
}
}
return ok;
}

View File

@ -691,10 +691,7 @@ ExprResolveString(ExprDef * expr,
}
val_rtrn->str = XkbcAtomGetString(expr->value.str);
if (val_rtrn->str == NULL)
{
static char *empty = "";
val_rtrn->str = empty;
}
val_rtrn->str = strdup("");
return True;
case ExprIdent:
if (lookup)
@ -731,9 +728,13 @@ ExprResolveString(ExprDef * expr,
if (new)
{
sprintf(new, "%s%s", leftRtrn.str, rightRtrn.str);
free(leftRtrn.str);
free(rightRtrn.str);
val_rtrn->str = new;
return True;
}
free(leftRtrn.str);
free(rightRtrn.str);
}
return False;
case OpSubtract:

View File

@ -1489,6 +1489,7 @@ SetShapeDoodadField(DoodadInfo * di,
}
di->shape = xkb_intern_atom(tmp.str);
di->defs.defined |= _GD_Shape;
free(tmp.str);
return True;
}
return ReportBadField(typeName, field, ddText(di));
@ -1621,6 +1622,7 @@ SetTextDoodadField(DoodadInfo * di,
}
di->defs.defined |= def;
*pField.str = xkb_intern_atom(tmp.str);
free(tmp.str);
}
else
{
@ -1683,6 +1685,7 @@ SetIndicatorDoodadField(DoodadInfo * di,
di->defs.defined |= _GD_Shape;
di->shape = xkb_intern_atom(tmp.str);
}
free(tmp.str);
return True;
}
return ReportBadField("indicator doodad", field, ddText(di));
@ -1743,6 +1746,7 @@ SetLogoDoodadField(DoodadInfo * di,
return ReportBadType(typeName, field, ddText(di), "string");
}
di->shape = xkb_intern_atom(tmp.str);
free(tmp.str);
di->defs.defined |= _GD_Shape;
return True;
}
@ -1761,6 +1765,7 @@ SetLogoDoodadField(DoodadInfo * di,
"string");
}
di->logoName = _XkbDupString(tmp.str);
free(tmp.str);
return True;
}
return ReportBadField(typeName, field, ddText(di));
@ -2613,12 +2618,20 @@ HandleComplexKey(KeyDef * def, KeyInfo * key, GeometryInfo * info)
{
if (!SetKeyField
(key, f.str, ndx, expr->value.binary.right, info))
{
free(elem.str);
free(f.str);
return False;
}
free(elem.str);
free(f.str);
}
else
{
ERROR("Illegal element used in a key definition\n");
ACTION("Assignment to %s.%s ignored\n", elem.str, f.str);
free(elem.str);
free(f.str);
return False;
}
}
@ -2689,6 +2702,8 @@ HandleRowBody(RowDef * def, RowInfo * row, unsigned merge,
WARN("Assignment to field of unknown element in row\n");
ACTION("No value assigned to %s.%s\n", elem.str, field.str);
}
free(elem.str);
free(field.str);
}
else if (keyDef->common.stmtType == StmtKeyDef)
{

View File

@ -615,6 +615,7 @@ HandleIncludeKeycodes(IncludeStmt * stmt, struct xkb_desc * xkb, KeyNamesInfo *
else
{
info->errorCount += 10; /* XXX: Why 10?? */
ClearKeyNamesInfo(&included);
return False;
}
}

View File

@ -435,6 +435,7 @@ HandleIncludeKeyTypes(IncludeStmt * stmt,
else
{
info->errorCount += 10;
FreeKeyTypesInfo(&included);
return False;
}
}
@ -951,9 +952,11 @@ HandleKeyTypeBody(VarDef * def,
continue;
}
ok = ExprResolveLhs(def->name, &tmp, &field, &arrayNdx);
if (ok)
if (ok) {
ok = SetKeyTypeField(type, xkb, field.str, arrayNdx, def->value,
info);
free(field.str);
}
}
return ok;
}
@ -1214,6 +1217,7 @@ CompileKeyTypes(XkbFile *file, struct xkb_desc * xkb, unsigned merge)
i++;
if (XkbcAllocClientMap(xkb, XkbKeyTypesMask, i) != Success)
{
FreeKeyTypesInfo(&info);
WSGO("Couldn't allocate client map\n");
return False;
}
@ -1226,6 +1230,7 @@ CompileKeyTypes(XkbFile *file, struct xkb_desc * xkb, unsigned merge)
keypadVMod = FindKeypadVMod(xkb);
if (XkbcInitCanonicalKeyTypes(xkb, missing, keypadVMod) != Success)
{
FreeKeyTypesInfo(&info);
WSGO("Couldn't initialize canonical key types\n");
return False;
}
@ -1252,11 +1257,16 @@ CompileKeyTypes(XkbFile *file, struct xkb_desc * xkb, unsigned merge)
else
type = next++;
DeleteLevel1MapEntries(def);
if (!CopyDefToKeyType(xkb, type, def))
if (!CopyDefToKeyType(xkb, type, def)) {
FreeKeyTypesInfo(&info);
return False;
}
def = (KeyTypeInfo *) def->defs.next;
}
FreeKeyTypesInfo(&info);
return True;
}
FreeKeyTypesInfo(&info);
return False;
}

View File

@ -226,7 +226,7 @@ InterpCreate(char *sym, ExprDef * match)
{
def->common.stmtType = StmtInterpDef;
def->common.next = NULL;
def->sym = strdup(sym);
def->sym = sym;
def->match = match;
}
else

View File

@ -1405,6 +1405,7 @@ SetGroupName(SymbolsInfo * info, ExprDef * arrayNdx, ExprDef * value)
}
info->groupNames[tmp.uval - 1 + info->explicit_group] =
xkb_intern_atom(name.str);
free(name.str);
return True;
}
@ -1527,9 +1528,9 @@ HandleSymbolsBody(VarDef * def,
{
if ((def->value == NULL)
|| (def->value->op == ExprKeysymList))
field.str = "symbols";
field.str = strdup("symbols");
else
field.str = "actions";
field.str = strdup("actions");
arrayNdx = NULL;
}
else
@ -1539,6 +1540,7 @@ HandleSymbolsBody(VarDef * def,
if (ok)
ok = SetSymbolsField(key, xkb, field.str, arrayNdx,
def->value, info);
free(field.str);
}
}
return ok;

View File

@ -392,7 +392,7 @@ KeyTypeDecl : TYPE String OBRACE
SymbolsDecl : KEY KeyName OBRACE
SymbolsBody
CBRACE SEMI
{ $$= SymbolsCreate($2,(ExprDef *)$4); }
{ $$= SymbolsCreate($2,(ExprDef *)$4); free($2); }
;
SymbolsBody : SymbolsBody COMMA SymbolsVarDecl