home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / patches / 7.4 / 7.4.320 < prev    next >
Encoding:
Internet Message Format  |  2014-06-11  |  4.3 KB

  1. To: vim_dev@googlegroups.com
  2. Subject: Patch 7.4.320
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. Mime-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. ------------
  9.  
  10. Patch 7.4.320
  11. Problem:    Possible crash when an BufLeave autocommand deletes the buffer.
  12. Solution:   Check for the window pointer being valid.  Postpone freeing the
  13.         window until autocommands are done. (Yasuhiro Matsumoto)
  14. Files:        src/buffer.c, src/fileio.c, src/globals.h, src/window.c
  15.  
  16.  
  17. *** ../vim-7.4.319/src/buffer.c    2014-05-07 16:35:05.029152844 +0200
  18. --- src/buffer.c    2014-06-12 13:47:17.799737639 +0200
  19. ***************
  20. *** 371,377 ****
  21.       unload_buf = TRUE;
  22.   #endif
  23.   
  24. !     if (win != NULL)
  25.       {
  26.       /* Set b_last_cursor when closing the last window for the buffer.
  27.        * Remember the last cursor position and window options of the buffer.
  28. --- 371,381 ----
  29.       unload_buf = TRUE;
  30.   #endif
  31.   
  32. !     if (win != NULL
  33. ! #ifdef FEAT_WINDOWS
  34. !     && win_valid(win)    /* in case autocommands closed the window */
  35. ! #endif
  36. !         )
  37.       {
  38.       /* Set b_last_cursor when closing the last window for the buffer.
  39.        * Remember the last cursor position and window options of the buffer.
  40. *** ../vim-7.4.319/src/fileio.c    2014-05-02 15:46:10.731268318 +0200
  41. --- src/fileio.c    2014-06-12 13:53:33.207751842 +0200
  42. ***************
  43. *** 9549,9555 ****
  44.   
  45.       /*
  46.        * When stopping to execute autocommands, restore the search patterns and
  47. !      * the redo buffer.  Free buffers in the au_pending_free_buf list.
  48.        */
  49.       if (!autocmd_busy)
  50.       {
  51. --- 9549,9556 ----
  52.   
  53.       /*
  54.        * When stopping to execute autocommands, restore the search patterns and
  55. !      * the redo buffer.  Free any buffers in the au_pending_free_buf list and
  56. !      * free any windows in the au_pending_free_win list.
  57.        */
  58.       if (!autocmd_busy)
  59.       {
  60. ***************
  61. *** 9562,9567 ****
  62. --- 9563,9574 ----
  63.           vim_free(au_pending_free_buf);
  64.           au_pending_free_buf = b;
  65.       }
  66. +     while (au_pending_free_win != NULL)
  67. +     {
  68. +         win_T *w = au_pending_free_win->w_next;
  69. +         vim_free(au_pending_free_win);
  70. +         au_pending_free_win = w;
  71. +     }
  72.       }
  73.   
  74.       /*
  75. *** ../vim-7.4.319/src/globals.h    2014-05-28 18:22:37.876225054 +0200
  76. --- src/globals.h    2014-06-12 13:54:29.163753959 +0200
  77. ***************
  78. *** 387,396 ****
  79.    * which one is preferred, au_new_curbuf is set to it */
  80.   EXTERN buf_T    *au_new_curbuf INIT(= NULL);
  81.   
  82. ! /* When deleting the buffer and autocmd_busy is TRUE, do not free the buffer
  83. !  * but link it in the list starting with au_pending_free_buf, using b_next.
  84. !  * Free the buffer when autocmd_busy is set to FALSE. */
  85.   EXTERN buf_T    *au_pending_free_buf INIT(= NULL);
  86.   #endif
  87.   
  88.   #ifdef FEAT_MOUSE
  89. --- 387,398 ----
  90.    * which one is preferred, au_new_curbuf is set to it */
  91.   EXTERN buf_T    *au_new_curbuf INIT(= NULL);
  92.   
  93. ! /* When deleting a buffer/window and autocmd_busy is TRUE, do not free the
  94. !  * buffer/window. but link it in the list starting with
  95. !  * au_pending_free_buf/ap_pending_free_win, using b_next/w_next.
  96. !  * Free the buffer/window when autocmd_busy is being set to FALSE. */
  97.   EXTERN buf_T    *au_pending_free_buf INIT(= NULL);
  98. + EXTERN win_T    *au_pending_free_win INIT(= NULL);
  99.   #endif
  100.   
  101.   #ifdef FEAT_MOUSE
  102. *** ../vim-7.4.319/src/window.c    2014-06-12 11:49:42.219470717 +0200
  103. --- src/window.c    2014-06-12 13:51:54.939748124 +0200
  104. ***************
  105. *** 4597,4603 ****
  106.       if (wp != aucmd_win)
  107.   #endif
  108.       win_remove(wp, tp);
  109. !     vim_free(wp);
  110.   
  111.   #ifdef FEAT_AUTOCMD
  112.       unblock_autocmds();
  113. --- 4597,4609 ----
  114.       if (wp != aucmd_win)
  115.   #endif
  116.       win_remove(wp, tp);
  117. !     if (autocmd_busy)
  118. !     {
  119. !     wp->w_next = au_pending_free_win;
  120. !     au_pending_free_win = wp;
  121. !     }
  122. !     else
  123. !     vim_free(wp);
  124.   
  125.   #ifdef FEAT_AUTOCMD
  126.       unblock_autocmds();
  127. *** ../vim-7.4.319/src/version.c    2014-06-12 13:28:26.771694851 +0200
  128. --- src/version.c    2014-06-12 13:40:23.507721966 +0200
  129. ***************
  130. *** 736,737 ****
  131. --- 736,739 ----
  132.   {   /* Add new patch number below this line */
  133. + /**/
  134. +     320,
  135.   /**/
  136.  
  137. -- 
  138. Life would be so much easier if we could just look at the source code.
  139.  
  140.  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
  141. ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
  142. \\\  an exciting new programming language -- http://www.Zimbu.org        ///
  143.  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
  144.