diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2018-02-02 02:30:21 +0100 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2018-02-11 15:27:57 +0100 |
commit | fd58863eb62edddf688a71d73448934efa188241 (patch) | |
tree | 8aa5c2ae70cc104817a381025d47b8b8d84ef9e1 /src/nvim/fileio.c | |
parent | 2d151f7739a072ee7239cc44efec2b43c1b72679 (diff) | |
download | rneovim-fd58863eb62edddf688a71d73448934efa188241.tar.gz rneovim-fd58863eb62edddf688a71d73448934efa188241.tar.bz2 rneovim-fd58863eb62edddf688a71d73448934efa188241.zip |
vim-patch:8.0.0703: illegal memory access with empty :doau command
Problem: Illegal memory access with empty :doau command.
Solution: Check the event for being out of range. (James McCoy)
https://github.com/vim/vim/commit/faf29d7f91477c25c85d9d7165d90e8d8f1c512e
Diffstat (limited to 'src/nvim/fileio.c')
-rw-r--r-- | src/nvim/fileio.c | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index 44d74c92cd..54b0032c9c 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -6274,13 +6274,13 @@ do_doautocmd ( fname = skipwhite(fname); - /* - * Loop over the events. - */ - while (*arg && !ascii_iswhite(*arg)) - if (apply_autocmds_group(event_name2nr(arg, &arg), - fname, NULL, TRUE, group, curbuf, NULL)) + // Loop over the events. + while (*arg && !ends_excmd(*arg) && !ascii_iswhite(*arg)) { + if (apply_autocmds_group(event_name2nr(arg, &arg), fname, NULL, TRUE, + group, curbuf, NULL)) { nothing_done = FALSE; + } + } if (nothing_done && do_msg) { MSG(_("No matching autocommands")); @@ -6671,12 +6671,12 @@ static bool apply_autocmds_group(event_T event, char_u *fname, char_u *fname_io, proftime_T wait_time; bool did_save_redobuff = false; - /* - * Quickly return if there are no autocommands for this event or - * autocommands are blocked. - */ - if (first_autopat[(int)event] == NULL || autocmd_blocked > 0) + // Quickly return if there are no autocommands for this event or + // autocommands are blocked. + if (event == NUM_EVENTS || first_autopat[(int)event] == NULL + || autocmd_blocked > 0) { goto BYPASS_AU; + } /* * When autocommands are busy, new autocommands are only executed when @@ -6742,18 +6742,21 @@ static bool apply_autocmds_group(event_T event, char_u *fname, char_u *fname_io, * invalid. */ if (fname_io == NULL) { - if (event == EVENT_COLORSCHEME || event == EVENT_OPTIONSET) + if (event == EVENT_COLORSCHEME || event == EVENT_OPTIONSET) { autocmd_fname = NULL; - else if (fname != NULL && *fname != NUL) + } else if (fname != NULL && !ends_excmd(*fname)) { autocmd_fname = fname; - else if (buf != NULL) + } else if (buf != NULL) { autocmd_fname = buf->b_ffname; - else + } else { autocmd_fname = NULL; - } else + } + } else { autocmd_fname = fname_io; - if (autocmd_fname != NULL) + } + if (autocmd_fname != NULL) { autocmd_fname = vim_strsave(autocmd_fname); + } autocmd_fname_full = FALSE; /* call FullName_save() later */ /* |