From 96776c831e9d2fcbd69bc1e0faa16026c5ed25b0 Mon Sep 17 00:00:00 2001 From: David Phillips Date: Fri, 29 Dec 2017 22:36:53 +1300 Subject: Fix use after free and memory leak --- parser.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'parser.c') diff --git a/parser.c b/parser.c index b756eae..2c4a7d6 100644 --- a/parser.c +++ b/parser.c @@ -201,6 +201,7 @@ parse_op(char *str, char *name) { int parse_expr(char *str) { + int ret = 0; const char *expr_sep = ": "; char *ident = NULL; char *next = NULL; @@ -217,7 +218,9 @@ parse_expr(char *str) { op = next + strlen(expr_sep); - return parse_op(op, ident); + ret = parse_op(op, ident); + free(ident); + return ret; } int @@ -297,12 +300,12 @@ parse_line(char *line) { } } - free(tok); - if (match == 0) { emit_error("invalid token \"%s\"", tok); + free(tok); return 1; } + free(tok); return 0; } -- cgit v1.1