Fix more bugs (mostly possible NULL pointer dereferences)

This commit is contained in:
Dale Weiler 2013-06-21 23:26:49 +00:00
parent 996d998ebb
commit fe296de42f
3 changed files with 4 additions and 3 deletions

2
ast.c
View file

@ -1563,7 +1563,7 @@ bool ast_global_codegen(ast_value *self, ir_builder *ir, bool isfield)
return true; return true;
error: /* clean up */ error: /* clean up */
ir_value_delete(v); if(v) ir_value_delete(v);
return false; return false;
} }

2
main.c
View file

@ -791,7 +791,7 @@ cleanup:
vec_free(ppems); vec_free(ppems);
if (!OPTS_OPTION_BOOL(OPTION_PP_ONLY)) if (!OPTS_OPTION_BOOL(OPTION_PP_ONLY))
parser_cleanup(parser); if(parser) parser_cleanup(parser);
if (opts_output_free) if (opts_output_free)
mem_d(OPTS_OPTION_STR(OPTION_OUTPUT)); mem_d(OPTS_OPTION_STR(OPTION_OUTPUT));
if (operators_free) if (operators_free)

View file

@ -3622,7 +3622,8 @@ static bool parse_goto(parser_t *parser, ast_expression **out)
if (!(expression = parse_expression(parser, false, true)) || if (!(expression = parse_expression(parser, false, true)) ||
!(*out = parse_goto_computed(parser, &expression))) { !(*out = parse_goto_computed(parser, &expression))) {
parseerror(parser, "invalid goto expression"); parseerror(parser, "invalid goto expression");
ast_unref(expression); if(expression)
ast_unref(expression);
return false; return false;
} }