neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit 7381f0a1d517474dcf8d8d019cbda430ce4bff23
parent 80eda9726f9fe0810b8d689a2c9c7821cb95a8d6
Author: bfredl <bjorn.linse@gmail.com>
Date:   Sun, 21 Jul 2024 16:29:16 +0200

Merge pull request #29650 from ruuzia/fix_expression_parser_crash

fix: assert failure in VimL expression parser
Diffstat:
Msrc/nvim/viml/parser/expressions.c | 9---------
Mtest/functional/api/vim_spec.lua | 7+++++++
2 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/src/nvim/viml/parser/expressions.c b/src/nvim/viml/parser/expressions.c @@ -1264,21 +1264,12 @@ static bool viml_pexpr_handle_bop(const ParserState *const pstate, ExprASTStack || bop_node->type == kExprNodeSubscript) ? kEOpLvlSubscript : node_lvl(*bop_node)); -#ifndef NDEBUG - const ExprOpAssociativity bop_node_ass = ( - (bop_node->type == kExprNodeCall - || bop_node->type == kExprNodeSubscript) - ? kEOpAssLeft - : node_ass(*bop_node)); -#endif do { ExprASTNode **new_top_node_p = kv_last(*ast_stack); ExprASTNode *new_top_node = *new_top_node_p; assert(new_top_node != NULL); const ExprOpLvl new_top_node_lvl = node_lvl(*new_top_node); const ExprOpAssociativity new_top_node_ass = node_ass(*new_top_node); - assert(bop_node_lvl != new_top_node_lvl - || bop_node_ass == new_top_node_ass); if (top_node_p != NULL && ((bop_node_lvl > new_top_node_lvl || (bop_node_lvl == new_top_node_lvl diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua @@ -2938,6 +2938,13 @@ describe('API', function() return ('%s(%s)%s'):format(typ, args, rest) end end + + it('does not crash parsing invalid VimL expression #29648', function() + api.nvim_input(':<C-r>=') + api.nvim_input('1bork/') + assert_alive() + end) + require('test.unit.viml.expressions.parser_tests')(it, _check_parsing, hl, fmtn) end)