]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
cmd: initialize cmd list and use list_splice_tail() for adding to command list
authorPatrick McHardy <kaber@trash.net>
Wed, 5 Feb 2014 19:03:40 +0000 (19:03 +0000)
committerPatrick McHardy <kaber@trash.net>
Wed, 5 Feb 2014 19:09:46 +0000 (19:09 +0000)
With incremental evaluation we're first evaluating the command before
adding it to the global command list, so the command's list_head is
uninitialized during evaluation. We need to initialize it to handle the
case that an implicit set declaration will prepend a command to the list.

Also list_splice_tail() needs to be used instead of list_add_tail() to
add the entire list of commands.

Signed-off-by: Patrick McHardy <kaber@trash.net>
src/parser.y
src/rule.c

index f6c9488a70929655ec5f022d95ee2565b80d37fd..2050f8a3c7fe6ab3088e0cd045579542524f7647 100644 (file)
@@ -497,7 +497,7 @@ input                       :       /* empty */
                                                if (++state->nerrs == max_errors)
                                                        YYABORT;
                                        } else
-                                               list_add_tail(&$2->list, &state->cmds);
+                                               list_splice_tail(&$2->list, &state->cmds);
                                }
                        }
                        ;
@@ -560,7 +560,7 @@ line                        :       common_block                    { $$ = NULL; }
                                                if (++state->nerrs == max_errors)
                                                        YYABORT;
                                        } else
-                                               list_add_tail(&$1->list, &state->cmds);
+                                               list_splice_tail(&$1->list, &state->cmds);
                                }
                                $$ = NULL;
 
index 657695a696d6d29d5754caf0e224a950001488a2..ab96e62ee2c02dfc06d31600ef595cd98885658c 100644 (file)
@@ -426,6 +426,7 @@ struct cmd *cmd_alloc(enum cmd_ops op, enum cmd_obj obj,
        struct cmd *cmd;
 
        cmd = xzalloc(sizeof(*cmd));
+       init_list_head(&cmd->list);
        cmd->op       = op;
        cmd->obj      = obj;
        cmd->handle   = *h;