dec5213
To: vim-dev@vim.org
dec5213
Subject: Patch 7.2.122
dec5213
Fcc: outbox
dec5213
From: Bram Moolenaar <Bram@moolenaar.net>
dec5213
Mime-Version: 1.0
dec5213
Content-Type: text/plain; charset=ISO-8859-1
dec5213
Content-Transfer-Encoding: 8bit
dec5213
------------
dec5213
dec5213
Patch 7.2.122
dec5213
Problem:    Invalid memory access when the VimResized autocommand changes
dec5213
            'columns' and/or 'lines'.
dec5213
Solution:   After VimResized check for changed values. (Dominique Pelle)
dec5213
Files:      src/screen.c
dec5213
dec5213
dec5213
*** ../vim-7.2.121/src/screen.c	Sun Feb 22 01:13:45 2009
dec5213
--- src/screen.c	Sun Feb 22 01:07:38 2009
dec5213
***************
dec5213
*** 7368,7374 ****
dec5213
--- 7368,7378 ----
dec5213
  #endif
dec5213
      static int	    entered = FALSE;		/* avoid recursiveness */
dec5213
      static int	    done_outofmem_msg = FALSE;	/* did outofmem message */
dec5213
+ #ifdef FEAT_AUTOCMD
dec5213
+     int		    retry_count = 0;
dec5213
  
dec5213
+ retry:
dec5213
+ #endif
dec5213
      /*
dec5213
       * Allocation of the screen buffers is done only when the size changes and
dec5213
       * when Rows and Columns have been set and we have started doing full
dec5213
***************
dec5213
*** 7643,7650 ****
dec5213
      --RedrawingDisabled;
dec5213
  
dec5213
  #ifdef FEAT_AUTOCMD
dec5213
!     if (starting == 0)
dec5213
  	apply_autocmds(EVENT_VIMRESIZED, NULL, NULL, FALSE, curbuf);
dec5213
  #endif
dec5213
  }
dec5213
  
dec5213
--- 7647,7663 ----
dec5213
      --RedrawingDisabled;
dec5213
  
dec5213
  #ifdef FEAT_AUTOCMD
dec5213
!     /*
dec5213
!      * Do not apply autocommands more than 3 times to avoid an endless loop
dec5213
!      * in case applying autocommands always changes Rows or Columns.
dec5213
!      */
dec5213
!     if (starting == 0 && ++retry_count <= 3)
dec5213
!     {
dec5213
  	apply_autocmds(EVENT_VIMRESIZED, NULL, NULL, FALSE, curbuf);
dec5213
+ 	/* In rare cases, autocommands may have altered Rows or Columns,
dec5213
+ 	 * jump back to check if we need to allocate the screen again. */
dec5213
+ 	goto retry;
dec5213
+     }
dec5213
  #endif
dec5213
  }
dec5213
  
dec5213
*** ../vim-7.2.121/src/version.c	Sun Feb 22 02:51:37 2009
dec5213
--- src/version.c	Sun Feb 22 21:11:14 2009
dec5213
***************
dec5213
*** 678,679 ****
dec5213
--- 678,681 ----
dec5213
  {   /* Add new patch number below this line */
dec5213
+ /**/
dec5213
+     122,
dec5213
  /**/
dec5213
dec5213
-- 
dec5213
FIXME and XXX are two common keywords used to mark broken or incomplete code
dec5213
not only since XXX as a sex reference would grab everbodys attention but
dec5213
simply due to the fact that Vim would highlight these words.
dec5213
					-- Hendrik Scholz
dec5213
dec5213
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
dec5213
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
dec5213
\\\        download, build and distribute -- http://www.A-A-P.org        ///
dec5213
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///