diff options
author | David Phillips <david@sighup.nz> | 2017-12-29 22:36:53 +1300 |
---|---|---|
committer | David Phillips <david@sighup.nz> | 2017-12-29 22:36:53 +1300 |
commit | 96776c831e9d2fcbd69bc1e0faa16026c5ed25b0 (patch) | |
tree | 6f3a56857bf8c7ff7b76628e0fa1b328ed488e39 | |
parent | 5f870b22b96f6f532d357478bede1cf646606909 (diff) | |
download | hence-96776c831e9d2fcbd69bc1e0faa16026c5ed25b0.tar.xz |
Fix use after free and memory leak
-rw-r--r-- | parser.c | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -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; } |