0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

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)
This commit is contained in:
Bram Moolenaar
2017-07-09 11:07:16 +02:00
parent c577d813b7
commit faf29d7f91
3 changed files with 10 additions and 3 deletions

View File

@@ -8863,7 +8863,7 @@ do_doautocmd(
/* /*
* Loop over the events. * Loop over the events.
*/ */
while (*arg && !VIM_ISWHITE(*arg)) while (*arg && !ends_excmd(*arg) && !VIM_ISWHITE(*arg))
if (apply_autocmds_group(event_name2nr(arg, &arg), if (apply_autocmds_group(event_name2nr(arg, &arg),
fname, NULL, TRUE, group, curbuf, NULL)) fname, NULL, TRUE, group, curbuf, NULL))
nothing_done = FALSE; nothing_done = FALSE;
@@ -9385,7 +9385,8 @@ apply_autocmds_group(
* Quickly return if there are no autocommands for this event or * Quickly return if there are no autocommands for this event or
* autocommands are blocked. * autocommands are blocked.
*/ */
if (first_autopat[(int)event] == NULL || autocmd_blocked > 0) if (event == NUM_EVENTS || first_autopat[(int)event] == NULL
|| autocmd_blocked > 0)
goto BYPASS_AU; goto BYPASS_AU;
/* /*
@@ -9458,7 +9459,7 @@ apply_autocmds_group(
{ {
if (event == EVENT_COLORSCHEME || event == EVENT_OPTIONSET) if (event == EVENT_COLORSCHEME || event == EVENT_OPTIONSET)
autocmd_fname = NULL; autocmd_fname = NULL;
else if (fname != NULL && *fname != NUL) else if (fname != NULL && !ends_excmd(*fname))
autocmd_fname = fname; autocmd_fname = fname;
else if (buf != NULL) else if (buf != NULL)
autocmd_fname = buf->b_ffname; autocmd_fname = buf->b_ffname;

View File

@@ -418,3 +418,7 @@ function Test_autocmd_bufwipe_in_SessLoadPost2()
call delete(file) call delete(file)
endfor endfor
endfunc endfunc
func Test_empty_doau()
doau \|
endfunc

View File

@@ -764,6 +764,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
703,
/**/ /**/
702, 702,
/**/ /**/