Fix memleak in parser: ==8445== 3,808 bytes in 2 blocks are definitely lost in loss record 6 of 6 ==8445== at 0x483577F: malloc (vg_replace_malloc.c:299) ==8445== by 0x112636: merge_options (conntrack.c:1056) ==8445== by 0x112636: do_parse (conntrack.c:2903) ==8445== by 0x11343E: ct_file_parse_line (conntrack.c:3672) ==8445== by 0x11343E: ct_parse_file (conntrack.c:3693) ==8445== by 0x10D819: main (conntrack.c:3750) Fixes: 8f76d6360dbf ("conntrack: add struct ct_cmd") Signed-off-by: Pablo Neira Ayuso <pablo@xxxxxxxxxxxxx> --- src/conntrack.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/conntrack.c b/src/conntrack.c index 4bc340f69cfc..879f7548d19f 100644 --- a/src/conntrack.c +++ b/src/conntrack.c @@ -3102,6 +3102,8 @@ static void do_parse(struct ct_cmd *ct_cmd, int argc, char *argv[]) if (!(command & CT_HELP) && h && h->final_check) h->final_check(l4flags, cmd, tmpl->ct); + free_options(); + ct_cmd->command = command; ct_cmd->cmd = cmd; ct_cmd->options = options; @@ -3536,7 +3538,6 @@ try_proc: err2str(errno, cmd->command)); free_tmpl_objects(&cmd->tmpl); - free_options(); if (labelmap) nfct_labelmap_destroy(labelmap); -- 2.20.1