]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
eval: use list_splice_tail() properly
authorPatrick McHardy <kaber@trash.net>
Thu, 6 Feb 2014 17:20:11 +0000 (17:20 +0000)
committerPatrick McHardy <kaber@trash.net>
Thu, 6 Feb 2014 17:20:16 +0000 (17:20 +0000)
We need a real list_head to splice both the command and potential new commands
added during evaluation.

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

index 2050f8a3c7fe6ab3088e0cd045579542524f7647..07613e2107c1bad06967bcfe0f04900041e3f95d 100644 (file)
@@ -492,12 +492,16 @@ input                     :       /* empty */
                        |       input           line
                        {
                                if ($2 != NULL) {
+                                       LIST_HEAD(list);
+
                                        $2->location = @2;
+
+                                       list_add_tail(&$2->list, &list);
                                        if (cmd_evaluate(&state->ectx, $2) < 0) {
                                                if (++state->nerrs == max_errors)
                                                        YYABORT;
                                        } else
-                                               list_splice_tail(&$2->list, &state->cmds);
+                                               list_splice_tail(&list, &state->cmds);
                                }
                        }
                        ;
@@ -554,13 +558,16 @@ line                      :       common_block                    { $$ = NULL; }
                                 * work.
                                 */
                                if ($1 != NULL) {
+                                       LIST_HEAD(list);
+
                                        $1->location = @1;
 
+                                       list_add_tail(&$1->list, &list);
                                        if (cmd_evaluate(&state->ectx, $1) < 0) {
                                                if (++state->nerrs == max_errors)
                                                        YYABORT;
                                        } else
-                                               list_splice_tail(&$1->list, &state->cmds);
+                                               list_splice_tail(&list, &state->cmds);
                                }
                                $$ = NULL;