]> git.rm.cloudns.org Git - xonotic/gmqcc.git/commitdiff
fixing a possible NULL deref
authorWolfgang Bumiller <blub@speed.at>
Wed, 16 Jan 2013 19:32:37 +0000 (20:32 +0100)
committerWolfgang Bumiller <blub@speed.at>
Wed, 16 Jan 2013 19:32:37 +0000 (20:32 +0100)
ast.c
parser.c

diff --git a/ast.c b/ast.c
index be8ce2e5aae7c14c7a12a55d4d34dfa3d242245c..5a553cfffbf3fe366084b9ba15e48d719853c03b 100644 (file)
--- a/ast.c
+++ b/ast.c
@@ -890,6 +890,11 @@ ast_call* ast_call_new(lex_ctx ctx,
                        ast_expression *funcexpr)
 {
     ast_instantiate(ast_call, ctx, ast_call_delete);
+    if (!funcexpr->expression.next) {
+        compile_error(ctx, "not a function");
+        mem_d(self);
+        return NULL;
+    }
     ast_expression_init((ast_expression*)self, (ast_expression_codegen*)&ast_call_codegen);
 
     ast_side_effects(self) = true;
index b86aac4a0cb3400faeee4c10ce48dbb2e3f6a3eb..2616081a1b52d0d7263494b03f57356d5dbc729f 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -1417,10 +1417,8 @@ static bool parser_close_call(parser_t *parser, shunt *sy)
     }
 
     call = ast_call_new(sy->ops[vec_size(sy->ops)].ctx, fun);
-    if (!call) {
-        parseerror(parser, "internal error: failed to create ast_call node");
+    if (!call)
         return false;
-    }
 
     if (fid+1 == vec_size(sy->out)) {
         /* no arguments */