]> granicus.if.org Git - vim/commitdiff
patch 8.0.0703: illegal memory access with empty :doau command v8.0.0703
authorBram Moolenaar <Bram@vim.org>
Sun, 9 Jul 2017 09:07:16 +0000 (11:07 +0200)
committerBram Moolenaar <Bram@vim.org>
Sun, 9 Jul 2017 09:07:16 +0000 (11:07 +0200)
Problem:    Illegal memory access with empty :doau command.
Solution:   Check the event for being out of range. (James McCoy)

src/fileio.c
src/testdir/test_autocmd.vim
src/version.c

index 0f59d809da472102bd69792ea232945f0d10a3c3..cac866c5c1d677e3e5400bf86e33a9225176ad81 100644 (file)
@@ -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;
index ef280340cc268b7c43d9dd6bbdac6a0f4f0e0377..54a2b3f1a5568c3e46c73faf564d0367967fd94e 100644 (file)
@@ -418,3 +418,7 @@ function Test_autocmd_bufwipe_in_SessLoadPost2()
     call delete(file)
   endfor
 endfunc
+
+func Test_empty_doau()
+  doau \|
+endfunc
index 70de1d4b7a6a95f64566a49d32b3810d926afa53..d494900b0e328fbd24d925a9b49aa476c8a51dd2 100644 (file)
@@ -764,6 +764,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    703,
 /**/
     702,
 /**/