changeset 11641:dbce7e03bf55 v8.0.0703

patch 8.0.0703: illegal memory access with empty :doau command commit https://github.com/vim/vim/commit/faf29d7f91477c25c85d9d7165d90e8d8f1c512e Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jul 9 11:07:16 2017 +0200 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)
author Christian Brabandt <cb@256bit.org>
date Sun, 09 Jul 2017 11:15:03 +0200
parents 54d6c5f6f2f0
children 389cb40dda69
files src/fileio.c src/testdir/test_autocmd.vim src/version.c
diffstat 3 files changed, 10 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -8863,7 +8863,7 @@ do_doautocmd(
     /*
      * 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),
 				      fname, NULL, TRUE, group, curbuf, NULL))
 	    nothing_done = FALSE;
@@ -9385,7 +9385,8 @@ apply_autocmds_group(
      * Quickly return if there are no autocommands for this event or
      * 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;
 
     /*
@@ -9458,7 +9459,7 @@ apply_autocmds_group(
     {
 	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)
 	    autocmd_fname = buf->b_ffname;
--- a/src/testdir/test_autocmd.vim
+++ b/src/testdir/test_autocmd.vim
@@ -418,3 +418,7 @@ function Test_autocmd_bufwipe_in_SessLoa
     call delete(file)
   endfor
 endfunc
+
+func Test_empty_doau()
+  doau \|
+endfunc
--- a/src/version.c
+++ b/src/version.c
@@ -765,6 +765,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    703,
+/**/
     702,
 /**/
     701,