From f534b9a7ca87cd3b170b6bb22449e51361d2a9e3 Mon Sep 17 00:00:00 2001 From: Patrick McHardy Date: Thu, 6 Feb 2014 17:20:11 +0000 Subject: eval: use list_splice_tail() properly We need a real list_head to splice both the command and potential new commands added during evaluation. Signed-off-by: Patrick McHardy --- src/parser.y | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/parser.y b/src/parser.y index 2050f8a3..07613e21 100644 --- a/src/parser.y +++ b/src/parser.y @@ -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; -- cgit v1.2.3