mirror of
https://github.com/neovim/neovim
synced 2025-07-16 01:01:49 +00:00
[Backport release-0.8] fix(api): nvim_create_autocmd crash on invalid types inside pattern array (#21777)
fix(api): nvim_create_autocmd crash on invalid types inside pattern array
(cherry picked from commit 46cef24321
)
Co-authored-by: ii14 <ii14@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
2b512a1d25
commit
5d5a155685
@ -972,7 +972,7 @@ static bool get_patterns_from_pattern_or_buf(Array *patterns, Object pattern, Ob
|
||||
patlen = aucmd_pattern_length(pat);
|
||||
}
|
||||
} else if (v->type == kObjectTypeArray) {
|
||||
if (!check_autocmd_string_array(*patterns, "pattern", err)) {
|
||||
if (!check_autocmd_string_array(v->data.array, "pattern", err)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -613,6 +613,20 @@ describe('autocmd api', function()
|
||||
eq(false, success)
|
||||
matches("'group' must be a string or an integer", code)
|
||||
end)
|
||||
|
||||
it('raises error for invalid pattern array', function()
|
||||
local success, code = unpack(meths.exec_lua([[
|
||||
return {pcall(function()
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = {{}},
|
||||
command = "echo 'hello'",
|
||||
})
|
||||
end)}
|
||||
]], {}))
|
||||
|
||||
eq(false, success)
|
||||
matches("All entries in 'pattern' must be strings", code)
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('patterns', function()
|
||||
|
Reference in New Issue
Block a user