Karsten Hopp 965fba
To: vim_dev@googlegroups.com
Karsten Hopp 965fba
Subject: Patch 7.3.822
Karsten Hopp 965fba
Fcc: outbox
Karsten Hopp 965fba
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 965fba
Mime-Version: 1.0
Karsten Hopp 965fba
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 965fba
Content-Transfer-Encoding: 8bit
Karsten Hopp 965fba
------------
Karsten Hopp 965fba
Karsten Hopp 965fba
Patch 7.3.822 (after 7.3.799)
Karsten Hopp 965fba
Problem:    Crash when accessing freed buffer.
Karsten Hopp 965fba
Solution:   Get 'textwidth' in caller of enter_buffer(). (Christian Brabandt)
Karsten Hopp 965fba
Files:	    src/buffer.c
Karsten Hopp 965fba
Karsten Hopp 965fba
Karsten Hopp 965fba
*** ../vim-7.3.821/src/buffer.c	2013-02-06 18:44:57.000000000 +0100
Karsten Hopp 965fba
--- src/buffer.c	2013-02-17 15:10:44.000000000 +0100
Karsten Hopp 965fba
***************
Karsten Hopp 965fba
*** 82,87 ****
Karsten Hopp 965fba
--- 82,90 ----
Karsten Hopp 965fba
  #ifdef FEAT_AUTOCMD
Karsten Hopp 965fba
      buf_T	*old_curbuf;
Karsten Hopp 965fba
  #endif
Karsten Hopp 965fba
+ #ifdef FEAT_SYN_HL
Karsten Hopp 965fba
+     long	old_tw = curbuf->b_p_tw;
Karsten Hopp 965fba
+ #endif
Karsten Hopp 965fba
  
Karsten Hopp 965fba
      /*
Karsten Hopp 965fba
       * The 'readonly' flag is only set when BF_NEVERLOADED is being reset.
Karsten Hopp 965fba
***************
Karsten Hopp 965fba
*** 113,118 ****
Karsten Hopp 965fba
--- 116,125 ----
Karsten Hopp 965fba
  	}
Karsten Hopp 965fba
  	EMSG(_("E83: Cannot allocate buffer, using other one..."));
Karsten Hopp 965fba
  	enter_buffer(curbuf);
Karsten Hopp 965fba
+ #ifdef FEAT_SYN_HL
Karsten Hopp 965fba
+ 	if (old_tw != curbuf->b_p_tw)
Karsten Hopp 965fba
+ 	    check_colorcolumn(curwin);
Karsten Hopp 965fba
+ #endif
Karsten Hopp 965fba
  	return FAIL;
Karsten Hopp 965fba
      }
Karsten Hopp 965fba
  
Karsten Hopp 965fba
***************
Karsten Hopp 965fba
*** 786,791 ****
Karsten Hopp 965fba
--- 793,801 ----
Karsten Hopp 965fba
  # if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
Karsten Hopp 965fba
      cleanup_T	cs;
Karsten Hopp 965fba
  # endif
Karsten Hopp 965fba
+ #ifdef FEAT_SYN_HL
Karsten Hopp 965fba
+     long	old_tw = curbuf->b_p_tw;
Karsten Hopp 965fba
+ #endif
Karsten Hopp 965fba
  
Karsten Hopp 965fba
      if (swap_exists_action == SEA_QUIT)
Karsten Hopp 965fba
      {
Karsten Hopp 965fba
***************
Karsten Hopp 965fba
*** 804,810 ****
Karsten Hopp 965fba
--- 814,826 ----
Karsten Hopp 965fba
  	if (!buf_valid(old_curbuf) || old_curbuf == curbuf)
Karsten Hopp 965fba
  	    old_curbuf = buflist_new(NULL, NULL, 1L, BLN_CURBUF | BLN_LISTED);
Karsten Hopp 965fba
  	if (old_curbuf != NULL)
Karsten Hopp 965fba
+ 	{
Karsten Hopp 965fba
  	    enter_buffer(old_curbuf);
Karsten Hopp 965fba
+ #ifdef FEAT_SYN_HL
Karsten Hopp 965fba
+ 	    if (old_tw != curbuf->b_p_tw)
Karsten Hopp 965fba
+ 		check_colorcolumn(curwin);
Karsten Hopp 965fba
+ #endif
Karsten Hopp 965fba
+ 	}
Karsten Hopp 965fba
  	/* If "old_curbuf" is NULL we are in big trouble here... */
Karsten Hopp 965fba
  
Karsten Hopp 965fba
  # if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
Karsten Hopp 965fba
***************
Karsten Hopp 965fba
*** 1364,1369 ****
Karsten Hopp 965fba
--- 1380,1388 ----
Karsten Hopp 965fba
      buf_T	*prevbuf;
Karsten Hopp 965fba
      int		unload = (action == DOBUF_UNLOAD || action == DOBUF_DEL
Karsten Hopp 965fba
  						     || action == DOBUF_WIPE);
Karsten Hopp 965fba
+ #ifdef FEAT_SYN_HL
Karsten Hopp 965fba
+     long	old_tw = curbuf->b_p_tw;
Karsten Hopp 965fba
+ #endif
Karsten Hopp 965fba
  
Karsten Hopp 965fba
      setpcmark();
Karsten Hopp 965fba
      if (!cmdmod.keepalt)
Karsten Hopp 965fba
***************
Karsten Hopp 965fba
*** 1430,1450 ****
Karsten Hopp 965fba
  # endif
Karsten Hopp 965fba
         )
Karsten Hopp 965fba
  #endif
Karsten Hopp 965fba
  	enter_buffer(buf);
Karsten Hopp 965fba
  }
Karsten Hopp 965fba
  
Karsten Hopp 965fba
  /*
Karsten Hopp 965fba
   * Enter a new current buffer.
Karsten Hopp 965fba
!  * Old curbuf must have been abandoned already!
Karsten Hopp 965fba
   */
Karsten Hopp 965fba
      void
Karsten Hopp 965fba
  enter_buffer(buf)
Karsten Hopp 965fba
      buf_T	*buf;
Karsten Hopp 965fba
  {
Karsten Hopp 965fba
- #ifdef FEAT_SYN_HL
Karsten Hopp 965fba
-     long old_tw = curbuf->b_p_tw;
Karsten Hopp 965fba
- #endif
Karsten Hopp 965fba
- 
Karsten Hopp 965fba
      /* Copy buffer and window local option values.  Not for a help buffer. */
Karsten Hopp 965fba
      buf_copy_options(buf, BCO_ENTER | BCO_NOHELP);
Karsten Hopp 965fba
      if (!buf->b_help)
Karsten Hopp 965fba
--- 1449,1472 ----
Karsten Hopp 965fba
  # endif
Karsten Hopp 965fba
         )
Karsten Hopp 965fba
  #endif
Karsten Hopp 965fba
+     {
Karsten Hopp 965fba
  	enter_buffer(buf);
Karsten Hopp 965fba
+ #ifdef FEAT_SYN_HL
Karsten Hopp 965fba
+ 	if (old_tw != curbuf->b_p_tw)
Karsten Hopp 965fba
+ 	    check_colorcolumn(curwin);
Karsten Hopp 965fba
+ #endif
Karsten Hopp 965fba
+     }
Karsten Hopp 965fba
  }
Karsten Hopp 965fba
  
Karsten Hopp 965fba
  /*
Karsten Hopp 965fba
   * Enter a new current buffer.
Karsten Hopp 965fba
!  * Old curbuf must have been abandoned already!  This also means "curbuf" may
Karsten Hopp 965fba
!  * be pointing to freed memory.
Karsten Hopp 965fba
   */
Karsten Hopp 965fba
      void
Karsten Hopp 965fba
  enter_buffer(buf)
Karsten Hopp 965fba
      buf_T	*buf;
Karsten Hopp 965fba
  {
Karsten Hopp 965fba
      /* Copy buffer and window local option values.  Not for a help buffer. */
Karsten Hopp 965fba
      buf_copy_options(buf, BCO_ENTER | BCO_NOHELP);
Karsten Hopp 965fba
      if (!buf->b_help)
Karsten Hopp 965fba
***************
Karsten Hopp 965fba
*** 1468,1475 ****
Karsten Hopp 965fba
  
Karsten Hopp 965fba
  #ifdef FEAT_SYN_HL
Karsten Hopp 965fba
      curwin->w_s = &(buf->b_s);
Karsten Hopp 965fba
-     if (old_tw != buf->b_p_tw)
Karsten Hopp 965fba
- 	check_colorcolumn(curwin);
Karsten Hopp 965fba
  #endif
Karsten Hopp 965fba
  
Karsten Hopp 965fba
      /* Cursor on first line by default. */
Karsten Hopp 965fba
--- 1490,1495 ----
Karsten Hopp 965fba
*** ../vim-7.3.821/src/version.c	2013-02-16 18:16:11.000000000 +0100
Karsten Hopp 965fba
--- src/version.c	2013-02-17 15:35:41.000000000 +0100
Karsten Hopp 965fba
***************
Karsten Hopp 965fba
*** 727,728 ****
Karsten Hopp 965fba
--- 727,730 ----
Karsten Hopp 965fba
  {   /* Add new patch number below this line */
Karsten Hopp 965fba
+ /**/
Karsten Hopp 965fba
+     822,
Karsten Hopp 965fba
  /**/
Karsten Hopp 965fba
Karsten Hopp 965fba
-- 
Karsten Hopp 965fba
Clothes make the man.  Naked people have little or no influence on society.
Karsten Hopp 965fba
                               -- Mark Twain (Samuel Clemens) (1835-1910)
Karsten Hopp 965fba
Karsten Hopp 965fba
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 965fba
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 965fba
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 965fba
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///