]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
libnftables: Fix memleak in nft_parse_bison_filename()
authorPhil Sutter <phil@nwl.cc>
Fri, 12 Oct 2018 11:22:55 +0000 (13:22 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 15 Oct 2018 11:37:51 +0000 (13:37 +0200)
Allocated scanner object leaks when returning to caller. For some odd
reason, this was missed by the commit referenced below.

Fixes: bd82e03e15df8 ("libnftables: Move scanner object into struct nft_ctx")
Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/libnftables.c

index 656b0a1c3f988cc45c433f6b94da38ea3b6d112b..977763793e7680722455e92bf581e7a6c3f8ab07 100644 (file)
@@ -420,15 +420,14 @@ static int nft_parse_bison_filename(struct nft_ctx *nft, const char *filename,
                                    struct list_head *msgs, struct list_head *cmds)
 {
        struct cmd *cmd;
-       void *scanner;
        int ret;
 
        parser_init(nft, nft->state, msgs, cmds);
-       scanner = scanner_init(nft->state);
-       if (scanner_read_file(scanner, filename, &internal_location) < 0)
+       nft->scanner = scanner_init(nft->state);
+       if (scanner_read_file(nft->scanner, filename, &internal_location) < 0)
                return -1;
 
-       ret = nft_parse(nft, scanner, nft->state);
+       ret = nft_parse(nft, nft->scanner, nft->state);
        if (ret != 0 || nft->state->nerrs > 0)
                return -1;