From 65ec6546fd1f52c6cc8e2c56e14c84d738934a5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=BCtzel?= Date: Fri, 13 Oct 2023 14:58:46 +0200 Subject: [PATCH] Avoid use-after-free issue (bug #60882). * libinterp/parse-tree/oct-parse.yy (base_parser::make_for_command): Avoid use-after-free in (unimplemented?) parfor block. --- libinterp/parse-tree/oct-parse.yy | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/libinterp/parse-tree/oct-parse.yy b/libinterp/parse-tree/oct-parse.yy index 4e759f37a4..6a975b8b36 100644 --- a/libinterp/parse-tree/oct-parse.yy +++ b/libinterp/parse-tree/oct-parse.yy @@ -3472,18 +3472,17 @@ OCTAVE_BEGIN_NAMESPACE(octave) delete lhs; } - else + else if (parfor) { - if (parfor) - { - delete lhs; - delete expr; - delete maxproc; - delete body; - - bison_error ("invalid syntax for parfor statement"); - } + delete lhs; + delete expr; + delete maxproc; + delete body; + bison_error ("invalid syntax for parfor statement"); + } + else + { m_lexer.mark_as_variables (lhs->variable_names ()); retval = new tree_complex_for_command (lhs, expr, body,