[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] cond expr: cleanup on errors
From: |
Grisha Levit |
Subject: |
Re: [PATCH] cond expr: cleanup on errors |
Date: |
Tue, 4 Jun 2024 15:00:14 -0400 |
On Mon, Jun 3, 2024 at 3:53 PM Chet Ramey <chet.ramey@case.edu> wrote:
>
> On 5/31/24 5:07 PM, Grisha Levit wrote:
> > Two minor leak fixes for conditional command error conditions:
> >
> > If a WORD token is read when COND_AND, COND_OR, COND_END, or a binary
> > operator are expected, the allocated WORD_DESC is leaked.
> >
> > If a conditional command has a syntax error, the allocated COMMAND is >
> > leaked.
>
> Thanks for the report. These are interactive errors only, since a syntax
> error in a compound command causes the shell to exit.
The fix for this you applied in [1] does seem cleaner. I think it needs
also the following for something like `[[ ( -n x x ]]`:
[1]: https://git.gnu.org/cgit/bash.git/commit/parse.y?h=devel&id=dbb48b97
diff --git a/parse.y b/parse.y
index eb83af4c..74f5d7ac 100644
--- a/parse.y
+++ b/parse.y
@@ -5041,6 +5041,8 @@ cond_term (void)
}
else
parser_error (lineno, _("expected `)'"));
+ if (cond_token == WORD)
+ dispose_word (yylval.word);
COND_RETURN_ERROR ();
}
term = make_cond_node (COND_EXPR, (WORD_DESC *)NULL, term,
(COND_COM *)NULL);