mirror of
https://github.com/neovim/neovim.git
synced 2026-08-29 18:41:48 +00:00
fix(api): parse_expression crash with unopened ] and node
Problem: nvim_parse_expression null pointer dereference with unmatched ] followed by a node. Solution: if ast_stack was empty, set new_top_node_p to top of the stack after pushing the list literal node; similar to what's done for curlies. This bug was originally found by a Matrix user, but I couldn't remember how to trigger it... Ran into the other crash while finding a repro. :P
This commit is contained in:
@@ -4755,6 +4755,38 @@ return function(itp, _check_parsing, hl, fmtn)
|
||||
hl('InvalidList', ']'),
|
||||
})
|
||||
|
||||
check_parsing(']a', {
|
||||
-- 01
|
||||
ast = {
|
||||
{
|
||||
'OpMissing:0:1:',
|
||||
children = {
|
||||
'ListLiteral:0:0:',
|
||||
'PlainIdentifier(scope=0,ident=a):0:1:a',
|
||||
},
|
||||
},
|
||||
},
|
||||
err = {
|
||||
arg = ']a',
|
||||
msg = 'E15: Unexpected closing figure brace: %.*s',
|
||||
},
|
||||
}, {
|
||||
hl('InvalidList', ']'),
|
||||
hl('InvalidIdentifierName', 'a'),
|
||||
}, {
|
||||
[1] = {
|
||||
ast = {
|
||||
len = 1,
|
||||
ast = {
|
||||
'ListLiteral:0:0:',
|
||||
},
|
||||
},
|
||||
hl_fs = {
|
||||
[2] = REMOVE_THIS,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
check_parsing('[] []', {
|
||||
-- 01234
|
||||
ast = {
|
||||
|
||||
Reference in New Issue
Block a user