Patch 7.4.2313
Problem:    Crash when deleting an augroup and listing an autocommand.
            (Dominique Pelle)
Solution:   Make sure deleted_augroup is valid.
Files:      src/fileio.c, src/testdir/test_autocmd.vim


*** ../vim-7.4.2312/src/fileio.c        2016-09-01 16:21:44.563629404 +0200
--- src/fileio.c        2016-09-03 16:38:15.597979072 +0200
***************
*** 7758,7763 ****
--- 7758,7764 ----
   */
  static garray_T augroups = {0, 0, sizeof(char_u *), 10, NULL};
  #define AUGROUP_NAME(i) (((char_u **)augroups.ga_data)[i])
+ /* use get_deleted_augroup() to get this */
  static char_u *deleted_augroup = NULL;
  
  /*
***************
*** 7790,7795 ****
--- 7791,7804 ----
  static int    last_group;
  static int    autocmd_blocked = 0;    /* block all autocmds */
  
+     static char_u *
+ get_deleted_augroup(void)
+ {
+     if (deleted_augroup == NULL)
+       deleted_augroup = (char_u *)_("--Deleted--");
+     return deleted_augroup;
+ }
+ 
  /*
   * Show the autocommands for one AutoPat.
   */
***************
*** 7813,7819 ****
        if (ap->group != AUGROUP_DEFAULT)
        {
            if (AUGROUP_NAME(ap->group) == NULL)
!               msg_puts_attr(deleted_augroup, hl_attr(HLF_E));
            else
                msg_puts_attr(AUGROUP_NAME(ap->group), hl_attr(HLF_T));
            msg_puts((char_u *)"  ");
--- 7822,7828 ----
        if (ap->group != AUGROUP_DEFAULT)
        {
            if (AUGROUP_NAME(ap->group) == NULL)
!               msg_puts_attr(get_deleted_augroup(), hl_attr(HLF_E));
            else
                msg_puts_attr(AUGROUP_NAME(ap->group), hl_attr(HLF_T));
            msg_puts((char_u *)"  ");
***************
*** 8029,8037 ****
        vim_free(AUGROUP_NAME(i));
        if (in_use)
        {
!           if (deleted_augroup == NULL)
!               deleted_augroup = (char_u *)_("--Deleted--");
!           AUGROUP_NAME(i) = deleted_augroup;
        }
        else
            AUGROUP_NAME(i) = NULL;
--- 8038,8044 ----
        vim_free(AUGROUP_NAME(i));
        if (in_use)
        {
!           AUGROUP_NAME(i) = get_deleted_augroup();
        }
        else
            AUGROUP_NAME(i) = NULL;
***************
*** 8048,8054 ****
      int           i;
  
      for (i = 0; i < augroups.ga_len; ++i)
!       if (AUGROUP_NAME(i) != NULL && AUGROUP_NAME(i) != deleted_augroup
                && STRCMP(AUGROUP_NAME(i), name) == 0)
            return i;
      return AUGROUP_ERROR;
--- 8055,8061 ----
      int           i;
  
      for (i = 0; i < augroups.ga_len; ++i)
!       if (AUGROUP_NAME(i) != NULL && AUGROUP_NAME(i) != get_deleted_augroup()
                && STRCMP(AUGROUP_NAME(i), name) == 0)
            return i;
      return AUGROUP_ERROR;
***************
*** 8116,8122 ****
      for (i = 0; i < augroups.ga_len; ++i)
      {
        s = ((char_u **)(augroups.ga_data))[i];
!       if (s != deleted_augroup)
            vim_free(s);
      }
      ga_clear(&augroups);
--- 8123,8129 ----
      for (i = 0; i < augroups.ga_len; ++i)
      {
        s = ((char_u **)(augroups.ga_data))[i];
!       if (s != get_deleted_augroup())
            vim_free(s);
      }
      ga_clear(&augroups);
***************
*** 9865,9871 ****
        return (char_u *)"END";
      if (idx >= augroups.ga_len)               /* end of list */
        return NULL;
!     if (AUGROUP_NAME(idx) == NULL || AUGROUP_NAME(idx) == deleted_augroup)
        /* skip deleted entries */
        return (char_u *)"";
      return AUGROUP_NAME(idx);         /* return a name */
--- 9872,9878 ----
        return (char_u *)"END";
      if (idx >= augroups.ga_len)               /* end of list */
        return NULL;
!     if (AUGROUP_NAME(idx) == NULL || AUGROUP_NAME(idx) == 
get_deleted_augroup())
        /* skip deleted entries */
        return (char_u *)"";
      return AUGROUP_NAME(idx);         /* return a name */
***************
*** 9931,9937 ****
      if (idx < augroups.ga_len)                /* First list group names, if 
wanted */
      {
        if (!include_groups || AUGROUP_NAME(idx) == NULL
!                                      || AUGROUP_NAME(idx) == deleted_augroup)
            return (char_u *)"";        /* skip deleted entries */
        return AUGROUP_NAME(idx);       /* return a name */
      }
--- 9938,9944 ----
      if (idx < augroups.ga_len)                /* First list group names, if 
wanted */
      {
        if (!include_groups || AUGROUP_NAME(idx) == NULL
!                                || AUGROUP_NAME(idx) == get_deleted_augroup())
            return (char_u *)"";        /* skip deleted entries */
        return AUGROUP_NAME(idx);       /* return a name */
      }
*** ../vim-7.4.2312/src/testdir/test_autocmd.vim        2016-09-01 
16:21:44.563629404 +0200
--- src/testdir/test_autocmd.vim        2016-09-03 16:33:51.488294199 +0200
***************
*** 183,185 ****
--- 183,194 ----
    redir END
    call assert_true(match(res, "W19:") < 0)
  endfunc
+ 
+ func Test_augroup_deleted()
+   " This caused a crash
+   augroup x
+   augroup! x
+   au VimEnter * echo
+   au VimEnter
+ endfunc
+ 
*** ../vim-7.4.2312/src/version.c       2016-09-03 16:29:01.450841139 +0200
--- src/version.c       2016-09-03 16:39:26.097361723 +0200
***************
*** 765,766 ****
--- 765,768 ----
  {   /* Add new patch number below this line */
+ /**/
+     2313,
  /**/


-- 
hundred-and-one symptoms of being an internet addict:
146. You experience ACTUAL physical withdrawal symptoms when away
     from your 'puter and the net.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui