From 9eb4c7c30bb6ee7dc8a6dae27c3bc82d537336ed Mon Sep 17 00:00:00 2001 From: pgen Date: Sun, 13 Oct 2019 20:28:07 +0200 Subject: [ctxopt] Fix a few memory leaks --- ctxopt.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'ctxopt.c') diff --git a/ctxopt.c b/ctxopt.c index add952c..11a8a95 100644 --- a/ctxopt.c +++ b/ctxopt.c @@ -1955,7 +1955,7 @@ success: *opt = xmalloc(sizeof(opt_t)); - (*opt)->name = xstrdup(opt_name); + (*opt)->name = opt_name; (*opt)->optional = opt_optional; (*opt)->multiple = opt_multiple; (*opt)->opt_count_matter = opt_count_matter; @@ -2983,6 +2983,7 @@ evaluate_ctx_inst(ctx_inst_t * ctx_inst) ll_node_t * opt_inst_node; char ** args; int nb_args; + int i; if (ctx_inst == NULL) return; @@ -3019,6 +3020,10 @@ evaluate_ctx_inst(ctx_inst_t * ctx_inst) if (opt_inst->next_ctx_inst != NULL) evaluate_ctx_inst(opt_inst->next_ctx_inst); + for (i = 0; i < nb_args; i++) + free(args[i]); + free(args); + opt_inst_node = opt_inst_node->next; } @@ -3206,6 +3211,8 @@ ctxopt_format_constraint(int nb_args, char ** args, char * value) error("The argument %s does not respect the imposed format: %s", value, args[0]); + free(format); + return rc == 1; } @@ -3235,6 +3242,8 @@ ctxopt_re_constraint(int nb_args, char ** args, char * value) return 0; } + regfree(&re); + return 1; } -- cgit v1.2.3