]> git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
After moving ast_instantiate up, the checks which return NULL now must mem_d(self)
authorWolfgang Bumiller <wolfgang.linux@bumiller.com>
Sat, 28 Apr 2012 22:41:35 +0000 (00:41 +0200)
committerWolfgang Bumiller <wolfgang.linux@bumiller.com>
Sat, 28 Apr 2012 22:41:35 +0000 (00:41 +0200)
ast.c

diff --git a/ast.c b/ast.c
index aede5aa2688fd7166d420a0521d3f66ec48cbac1..faba42527df9780ebfc9ca213d3c9056ab42aaf2 100644 (file)
--- a/ast.c
+++ b/ast.c
@@ -181,13 +181,14 @@ void ast_block_delete(ast_block *self)
 ast_function* ast_function_new(lex_ctx ctx, const char *name, ast_value *vtype)
 {
     ast_instantiate(ast_function, ctx, ast_function_delete);
-    
-    if (!vtype)
-        return NULL;
-    if (vtype->isconst)
-        return NULL;
-    if (vtype->vtype != TYPE_FUNCTION)
+
+    if (!vtype ||
+        vtype->isconst ||
+        vtype->vtype != TYPE_FUNCTION)
+    {
+        mem_d(self);
         return NULL;
+    }
 
     self->vtype = vtype;
     self->name = name ? util_strdup(name) : NULL;