From bb16416ec82599e41043a52887c37157e6f61984 Mon Sep 17 00:00:00 2001 From: Florian Westphal Date: Mon, 19 Jun 2023 22:43:03 +0200 Subject: parser: don't assert on scope underflows close_scope() gets called from the object destructors; imbalance can cause us to hit assert(). Before: nft: parser_bison.y:88: close_scope: Assertion `state->scope > 0' failed. After: assertion3:4:7-7: Error: too many levels of nesting jump { assertion3:5:8-8: Error: too many levels of nesting jump assertion3:5:9-9: Error: syntax error, unexpected newline, expecting '{' assertion3:7:1-1: Error: syntax error, unexpected end of file Signed-off-by: Florian Westphal --- src/parser_bison.y | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/parser_bison.y') diff --git a/src/parser_bison.y b/src/parser_bison.y index 763c1b2d..f5f6bf04 100644 --- a/src/parser_bison.y +++ b/src/parser_bison.y @@ -80,12 +80,11 @@ static int open_scope(struct parser_state *state, struct scope *scope) static void close_scope(struct parser_state *state) { - if (state->scope_err) { + if (state->scope_err || state->scope == 0) { state->scope_err = false; return; } - assert(state->scope > 0); state->scope--; } -- cgit v1.2.3