From: Wolfgang Bumiller Date: Wed, 16 Jan 2013 19:32:37 +0000 (+0100) Subject: fixing a possible NULL deref X-Git-Tag: before-library~245 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=00a9d2a9e3f8ad23515dd519fc388a5afa6a170a;p=xonotic%2Fgmqcc.git fixing a possible NULL deref --- diff --git a/ast.c b/ast.c index be8ce2e..5a553cf 100644 --- 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; diff --git a/parser.c b/parser.c index b86aac4..2616081 100644 --- 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 */