]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
parser_bison: release parsed type and hook name strings
authorPablo Neira Ayuso <pablo@netfilter.org>
Tue, 15 Mar 2016 16:15:10 +0000 (17:15 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Tue, 15 Mar 2016 16:32:33 +0000 (17:32 +0100)
The scanner allocates memory for this, so release them given that we
don't attach them to any object.

==6277== 42 bytes in 6 blocks are definitely lost in loss record 2 of 4
==6277==    at 0x4C28C20: malloc (vg_replace_malloc.c:296)
==6277==    by 0x57AC9D9: strdup (strdup.c:42)
==6277==    by 0x41B82D: xstrdup (utils.c:64)
==6277==    by 0x41F510: nft_lex (scanner.l:511)
==6277==    by 0x427FD1: nft_parse (parser_bison.c:3690)
==6277==    by 0x4063AC: nft_run (main.c:231)
==6277==    by 0x40600C: main (main.c:361)

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/parser_bison.y

index 0592b682092ba20efde01630a7c15291799f6aa1..9e86f2650450555e2574ad7e1edcb26183ae2533 100644 (file)
@@ -1107,12 +1107,16 @@ hook_spec               :       TYPE            STRING          HOOK            STRING          dev_spec        PRIORITY        prio_spec
                                                   state->msgs);
                                        YYERROR;
                                }
+                               xfree($2);
+
                                $<chain>0->hookstr      = chain_hookname_lookup($4);
                                if ($<chain>0->hookstr == NULL) {
                                        erec_queue(error(&@4, "unknown chain hook %s", $4),
                                                   state->msgs);
                                        YYERROR;
                                }
+                               xfree($4);
+
                                $<chain>0->dev          = $5;
                                $<chain>0->priority     = $7;
                                $<chain>0->flags        |= CHAIN_F_BASECHAIN;