summaryrefslogtreecommitdiffstats
path: root/ctxopt.c
diff options
context:
space:
mode:
authorpgen <p.gen.progs@gmail.com>2019-10-13 20:28:07 +0200
committerpgen <p.gen.progs@gmail.com>2019-10-13 23:22:36 +0200
commit9eb4c7c30bb6ee7dc8a6dae27c3bc82d537336ed (patch)
tree75e3a0170310b5d805ac6ff0d9a729e839f922bd /ctxopt.c
parent089bea72025f374e30471309d6d6254f86d74709 (diff)
[ctxopt] Fix a few memory leaks
Diffstat (limited to 'ctxopt.c')
-rw-r--r--ctxopt.c11
1 files changed, 10 insertions, 1 deletions
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;
}