ast-build: don't leak on OOM in BoolVarCreate
authorRan Benita <ran234@gmail.com>
Sun, 11 May 2014 06:47:56 +0000 (09:47 +0300)
committerRan Benita <ran234@gmail.com>
Sun, 11 May 2014 06:47:56 +0000 (09:47 +0300)
Signed-off-by: Ran Benita <ran234@gmail.com>
src/xkbcomp/ast-build.c

index 11bc091..2a28436 100644 (file)
@@ -303,8 +303,15 @@ VarCreate(ExprDef *name, ExprDef *value)
 VarDef *
 BoolVarCreate(xkb_atom_t ident, bool set)
 {
-    return VarCreate((ExprDef *) ExprCreateIdent(ident),
-                     (ExprDef *) ExprCreateBoolean(set));
+    ExprDef *name, *value;
+    if (!(name = ExprCreateIdent(ident))) {
+        return NULL;
+    }
+    if (!(value = ExprCreateBoolean(set))) {
+        FreeStmt((ParseCommon *) name);
+        return NULL;
+    }
+    return VarCreate(name, value);
 }
 
 InterpDef *