ast-build: fix leak in error path Signed-off-by: Ran Benita <ran234@gmail.com>
diff --git a/src/xkbcomp/ast-build.c b/src/xkbcomp/ast-build.c
index 58c482c..7fd92a6 100644
--- a/src/xkbcomp/ast-build.c
+++ b/src/xkbcomp/ast-build.c
@@ -304,6 +304,7 @@ VarDef *
BoolVarCreate(xkb_atom_t ident, bool set)
{
ExprDef *name, *value;
+ VarDef *def;
if (!(name = ExprCreateIdent(ident))) {
return NULL;
}
@@ -311,7 +312,12 @@ BoolVarCreate(xkb_atom_t ident, bool set)
FreeStmt((ParseCommon *) name);
return NULL;
}
- return VarCreate(name, value);
+ if (!(def = VarCreate(name, value))) {
+ FreeStmt((ParseCommon *) name);
+ FreeStmt((ParseCommon *) value);
+ return NULL;
+ }
+ return def;
}
InterpDef *