summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Phillips <david@sighup.nz>2017-12-29 22:36:53 +1300
committerDavid Phillips <david@sighup.nz>2017-12-29 22:36:53 +1300
commit96776c831e9d2fcbd69bc1e0faa16026c5ed25b0 (patch)
tree6f3a56857bf8c7ff7b76628e0fa1b328ed488e39
parent5f870b22b96f6f532d357478bede1cf646606909 (diff)
downloadhence-96776c831e9d2fcbd69bc1e0faa16026c5ed25b0.tar.xz
Fix use after free and memory leak
-rw-r--r--parser.c9
1 files changed, 6 insertions, 3 deletions
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;
}