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) XkbcFreeControls(struct xkb_desc * xkb, unsigned which, Bool freeMap)
{ {
if (freeMap && xkb && xkb->ctrls) { if (freeMap && xkb && xkb->ctrls) {
free(xkb->ctrls->per_key_repeat);
free(xkb->ctrls); free(xkb->ctrls);
xkb->ctrls = NULL; xkb->ctrls = NULL;
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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