From 00a9d2a9e3f8ad23515dd519fc388a5afa6a170a Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Wed, 16 Jan 2013 20:32:37 +0100 Subject: [PATCH] fixing a possible NULL deref --- ast.c | 5 +++++ parser.c | 4 +--- 2 files changed, 6 insertions(+), 3 deletions(-) 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 */ -- 2.39.2