aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api/autocmd.c
diff options
context:
space:
mode:
authorii14 <59243201+ii14@users.noreply.github.com>2023-10-09 11:50:44 +0200
committerGitHub <noreply@github.com>2023-10-09 02:50:44 -0700
commit139e6f68f937b9efcadf2709ee1c83213d3266fa (patch)
tree7daa6dbc0f9c207980a2757620cfcc2c6f6f42d9 /src/nvim/api/autocmd.c
parent8e932480f61d6101bf8bea1abc07ed93826221fd (diff)
downloadrneovim-139e6f68f937b9efcadf2709ee1c83213d3266fa.tar.gz
rneovim-139e6f68f937b9efcadf2709ee1c83213d3266fa.tar.bz2
rneovim-139e6f68f937b9efcadf2709ee1c83213d3266fa.zip
fix(autocmd): API functions accept garbage after event name #25523
"VimEnter foo" was accepted as a valid event name for "VimEnter". Events delimited with commas, eg. "VimEnter,BufRead", were also accepted, even though only the first event was actually parsed. Co-authored-by: ii14 <ii14@users.noreply.github.com>
Diffstat (limited to 'src/nvim/api/autocmd.c')
-rw-r--r--src/nvim/api/autocmd.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/nvim/api/autocmd.c b/src/nvim/api/autocmd.c
index 768ed869cc..d19f44798b 100644
--- a/src/nvim/api/autocmd.c
+++ b/src/nvim/api/autocmd.c
@@ -33,13 +33,11 @@
// Copy string or array of strings into an empty array.
// Get the event number, unless it is an error. Then goto `goto_name`.
#define GET_ONE_EVENT(event_nr, event_str, goto_name) \
- char *__next_ev; \
event_T event_nr = \
- event_name2nr(event_str.data.string.data, &__next_ev); \
- if (event_nr >= NUM_EVENTS) { \
- api_set_error(err, kErrorTypeValidation, "unexpected event"); \
+ event_name2nr_str(event_str.data.string); \
+ VALIDATE_S((event_nr < NUM_EVENTS), "event", event_str.data.string.data, { \
goto goto_name; \
- }
+ });
// ID for associating autocmds created via nvim_create_autocmd
// Used to delete autocmds from nvim_del_autocmd