aboutsummaryrefslogtreecommitdiff
path: root/read_config_file.c
diff options
context:
space:
mode:
authorPetr Machata <pmachata@redhat.com>2012-10-29 15:26:34 +0100
committerPetr Machata <pmachata@redhat.com>2012-10-29 15:26:34 +0100
commiteb1286520c36957fa6bbf28a4146b68699f75948 (patch)
treef1227c7c039f18681854f340f0bfc74a221bc316 /read_config_file.c
parent2ee358f27c14dfb25c315237765c709e1716109b (diff)
downloadltrace-eb1286520c36957fa6bbf28a4146b68699f75948.tar.gz
Release identifier name when we are done parsing it
This plugs a leak.
Diffstat (limited to 'read_config_file.c')
-rw-r--r--read_config_file.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/read_config_file.c b/read_config_file.c
index 9ed9d30..8391e10 100644
--- a/read_config_file.c
+++ b/read_config_file.c
@@ -287,17 +287,19 @@ parse_argnum(char **str, int zero)
return expr;
} else {
- char *name = parse_ident(str);
- if (name == NULL)
+ char *const name = parse_ident(str);
+ if (name == NULL) {
+ fail_ident:
+ free(name);
goto fail;
+ }
int is_arg = strncmp(name, "arg", 3) == 0;
if (is_arg || strncmp(name, "elt", 3) == 0) {
long l;
- name += 3;
- if (parse_int(&name, &l) < 0
- || check_int(l) < 0)
- goto fail;
+ char *num = name + 3;
+ if (parse_int(&num, &l) < 0 || check_int(l) < 0)
+ goto fail_ident;
if (is_arg) {
if (l == 0)
@@ -310,7 +312,7 @@ parse_argnum(char **str, int zero)
if (e_up == NULL || e_ix == NULL) {
free(e_up);
free(e_ix);
- goto fail;
+ goto fail_ident;
}
expr_init_up(e_up, expr_self(), 0);
@@ -326,18 +328,19 @@ parse_argnum(char **str, int zero)
} else if (strcmp(name, "zero") == 0) {
struct expr_node *ret = parse_zero(str, expr);
if (ret == NULL)
- goto fail;
+ goto fail_ident;
return ret;
} else {
report_error(filename, line_no,
"Unknown length specifier: '%s'", name);
- goto fail;
+ goto fail_ident;
}
if (zero && wrap_in_zero(&expr) < 0)
- goto fail;
+ goto fail_ident;
+ free(name);
return expr;
}