]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
parser: Fix for memleak when commands fail
authorPhil Sutter <phil@nwl.cc>
Thu, 24 Aug 2017 17:14:13 +0000 (19:14 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Thu, 24 Aug 2017 17:20:29 +0000 (19:20 +0200)
In case of failing command evaluation, commands need to be freed as
their memory becomes orphaned afterwards.

Signed-off-by: Phil Sutter <phil@nwl.cc>
src/parser_bison.y

index a8b71cddc192030737075ece45faa08dc9d86deb..d149178c2679bbd4d88bb3fc8a145bd504aac83f 100644 (file)
@@ -692,6 +692,7 @@ input                       :       /* empty */
 
                                        list_add_tail(&$2->list, &list);
                                        if (cmd_evaluate(&state->ectx, $2) < 0) {
+                                               cmd_free($2);
                                                if (++state->nerrs == nft->parser_max_errors)
                                                        YYABORT;
                                        } else
@@ -758,6 +759,7 @@ line                        :       common_block                    { $$ = NULL; }
 
                                        list_add_tail(&$1->list, &list);
                                        if (cmd_evaluate(&state->ectx, $1) < 0) {
+                                               cmd_free($1);
                                                if (++state->nerrs == nft->parser_max_errors)
                                                        YYABORT;
                                        } else