From d7a25b6cf63ae12f4e0c40d463d0b01fbc1e43fc Mon Sep 17 00:00:00 2001 From: Petr Machata Date: Wed, 6 Nov 2013 11:16:41 +0100 Subject: [PATCH] Plug a leak --- read_config_file.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/read_config_file.c b/read_config_file.c index 980b89b..b59cff4 100644 --- a/read_config_file.c +++ b/read_config_file.c @@ -678,6 +678,7 @@ build_printf_pack(struct locus *loc, struct param **packp, size_t param_num) struct expr_node *node = malloc(sizeof(*node)); if (node == NULL) { free(*packp); + *packp = NULL; return -1; } @@ -1125,12 +1126,19 @@ process_line(struct protolib *plib, struct locus *loc, char *buf) struct prototype fun; prototype_init(&fun); + struct param *extra_param = NULL; char *proto_name = NULL; int own; fun.return_info = parse_lens(plib, loc, &str, NULL, 0, &own, NULL); if (fun.return_info == NULL) { err: debug(3, " Skipping line %d", loc->line_no); + + if (extra_param != NULL) { + param_destroy(extra_param); + free(extra_param); + } + prototype_destroy(&fun); free(proto_name); return -1; @@ -1157,7 +1165,6 @@ process_line(struct protolib *plib, struct locus *loc, char *buf) str = tmp + 1; debug(3, " name = %s", proto_name); - struct param *extra_param = NULL; int have_stop = 0; while (1) { @@ -1235,6 +1242,7 @@ process_line(struct protolib *plib, struct locus *loc, char *buf) if (extra_param != NULL) { prototype_push_param(&fun, extra_param); free(extra_param); + extra_param = NULL; } if (protolib_add_prototype(plib, proto_name, 1, &fun) < 0) { -- 2.7.4