fixing a possible NULL deref

This commit is contained in:
Wolfgang Bumiller 2013-01-16 20:32:37 +01:00
parent e311dffcb3
commit 00a9d2a9e3
2 changed files with 6 additions and 3 deletions

5
ast.c
View file

@ -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;

View file

@ -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 */