Karsten Hopp 365b69
To: vim_dev@googlegroups.com
Karsten Hopp 365b69
Subject: Patch 7.4.797
Karsten Hopp 365b69
Fcc: outbox
Karsten Hopp 365b69
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 365b69
Mime-Version: 1.0
Karsten Hopp 365b69
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 365b69
Content-Transfer-Encoding: 8bit
Karsten Hopp 365b69
------------
Karsten Hopp 365b69
Karsten Hopp 365b69
Patch 7.4.797
Karsten Hopp 365b69
Problem:    Crash when using more lines for the command line than
Karsten Hopp 365b69
            'maxcombine'.
Karsten Hopp 365b69
Solution:   Use the correct array index.  Also, do not try redrawing when
Karsten Hopp 365b69
            exiting.  And use screen_Columns instead of Columns.
Karsten Hopp 365b69
Files:      src/screen.c
Karsten Hopp 365b69
Karsten Hopp 365b69
Karsten Hopp 365b69
*** ../vim-7.4.796/src/screen.c	2015-07-21 15:48:13.589517950 +0200
Karsten Hopp 365b69
--- src/screen.c	2015-07-25 22:46:44.028355647 +0200
Karsten Hopp 365b69
***************
Karsten Hopp 365b69
*** 279,284 ****
Karsten Hopp 365b69
--- 279,285 ----
Karsten Hopp 365b69
      int		type;
Karsten Hopp 365b69
  {
Karsten Hopp 365b69
      int		rows;
Karsten Hopp 365b69
+     int		cols = screen_Columns;
Karsten Hopp 365b69
      int		r;
Karsten Hopp 365b69
      int		ret = 0;
Karsten Hopp 365b69
      schar_T	*screenline;	/* copy from ScreenLines[] */
Karsten Hopp 365b69
***************
Karsten Hopp 365b69
*** 291,318 ****
Karsten Hopp 365b69
  #endif
Karsten Hopp 365b69
  
Karsten Hopp 365b69
      redraw_later(type);
Karsten Hopp 365b69
!     if (msg_scrolled || (State != NORMAL && State != NORMAL_BUSY))
Karsten Hopp 365b69
  	return ret;
Karsten Hopp 365b69
  
Karsten Hopp 365b69
      /* Allocate space to save the text displayed in the command line area. */
Karsten Hopp 365b69
!     rows = Rows - cmdline_row;
Karsten Hopp 365b69
      screenline = (schar_T *)lalloc(
Karsten Hopp 365b69
! 			   (long_u)(rows * Columns * sizeof(schar_T)), FALSE);
Karsten Hopp 365b69
      screenattr = (sattr_T *)lalloc(
Karsten Hopp 365b69
! 			   (long_u)(rows * Columns * sizeof(sattr_T)), FALSE);
Karsten Hopp 365b69
      if (screenline == NULL || screenattr == NULL)
Karsten Hopp 365b69
  	ret = 2;
Karsten Hopp 365b69
  #ifdef FEAT_MBYTE
Karsten Hopp 365b69
      if (enc_utf8)
Karsten Hopp 365b69
      {
Karsten Hopp 365b69
  	screenlineUC = (u8char_T *)lalloc(
Karsten Hopp 365b69
! 			  (long_u)(rows * Columns * sizeof(u8char_T)), FALSE);
Karsten Hopp 365b69
  	if (screenlineUC == NULL)
Karsten Hopp 365b69
  	    ret = 2;
Karsten Hopp 365b69
  	for (i = 0; i < p_mco; ++i)
Karsten Hopp 365b69
  	{
Karsten Hopp 365b69
  	    screenlineC[i] = (u8char_T *)lalloc(
Karsten Hopp 365b69
! 			  (long_u)(rows * Columns * sizeof(u8char_T)), FALSE);
Karsten Hopp 365b69
  	    if (screenlineC[i] == NULL)
Karsten Hopp 365b69
  		ret = 2;
Karsten Hopp 365b69
  	}
Karsten Hopp 365b69
--- 292,319 ----
Karsten Hopp 365b69
  #endif
Karsten Hopp 365b69
  
Karsten Hopp 365b69
      redraw_later(type);
Karsten Hopp 365b69
!     if (msg_scrolled || (State != NORMAL && State != NORMAL_BUSY) || exiting)
Karsten Hopp 365b69
  	return ret;
Karsten Hopp 365b69
  
Karsten Hopp 365b69
      /* Allocate space to save the text displayed in the command line area. */
Karsten Hopp 365b69
!     rows = screen_Rows - cmdline_row;
Karsten Hopp 365b69
      screenline = (schar_T *)lalloc(
Karsten Hopp 365b69
! 			   (long_u)(rows * cols * sizeof(schar_T)), FALSE);
Karsten Hopp 365b69
      screenattr = (sattr_T *)lalloc(
Karsten Hopp 365b69
! 			   (long_u)(rows * cols * sizeof(sattr_T)), FALSE);
Karsten Hopp 365b69
      if (screenline == NULL || screenattr == NULL)
Karsten Hopp 365b69
  	ret = 2;
Karsten Hopp 365b69
  #ifdef FEAT_MBYTE
Karsten Hopp 365b69
      if (enc_utf8)
Karsten Hopp 365b69
      {
Karsten Hopp 365b69
  	screenlineUC = (u8char_T *)lalloc(
Karsten Hopp 365b69
! 			  (long_u)(rows * cols * sizeof(u8char_T)), FALSE);
Karsten Hopp 365b69
  	if (screenlineUC == NULL)
Karsten Hopp 365b69
  	    ret = 2;
Karsten Hopp 365b69
  	for (i = 0; i < p_mco; ++i)
Karsten Hopp 365b69
  	{
Karsten Hopp 365b69
  	    screenlineC[i] = (u8char_T *)lalloc(
Karsten Hopp 365b69
! 			  (long_u)(rows * cols * sizeof(u8char_T)), FALSE);
Karsten Hopp 365b69
  	    if (screenlineC[i] == NULL)
Karsten Hopp 365b69
  		ret = 2;
Karsten Hopp 365b69
  	}
Karsten Hopp 365b69
***************
Karsten Hopp 365b69
*** 320,326 ****
Karsten Hopp 365b69
      if (enc_dbcs == DBCS_JPNU)
Karsten Hopp 365b69
      {
Karsten Hopp 365b69
  	screenline2 = (schar_T *)lalloc(
Karsten Hopp 365b69
! 			   (long_u)(rows * Columns * sizeof(schar_T)), FALSE);
Karsten Hopp 365b69
  	if (screenline2 == NULL)
Karsten Hopp 365b69
  	    ret = 2;
Karsten Hopp 365b69
      }
Karsten Hopp 365b69
--- 321,327 ----
Karsten Hopp 365b69
      if (enc_dbcs == DBCS_JPNU)
Karsten Hopp 365b69
      {
Karsten Hopp 365b69
  	screenline2 = (schar_T *)lalloc(
Karsten Hopp 365b69
! 			   (long_u)(rows * cols * sizeof(schar_T)), FALSE);
Karsten Hopp 365b69
  	if (screenline2 == NULL)
Karsten Hopp 365b69
  	    ret = 2;
Karsten Hopp 365b69
      }
Karsten Hopp 365b69
***************
Karsten Hopp 365b69
*** 331,357 ****
Karsten Hopp 365b69
  	/* Save the text displayed in the command line area. */
Karsten Hopp 365b69
  	for (r = 0; r < rows; ++r)
Karsten Hopp 365b69
  	{
Karsten Hopp 365b69
! 	    mch_memmove(screenline + r * Columns,
Karsten Hopp 365b69
  			ScreenLines + LineOffset[cmdline_row + r],
Karsten Hopp 365b69
! 			(size_t)Columns * sizeof(schar_T));
Karsten Hopp 365b69
! 	    mch_memmove(screenattr + r * Columns,
Karsten Hopp 365b69
  			ScreenAttrs + LineOffset[cmdline_row + r],
Karsten Hopp 365b69
! 			(size_t)Columns * sizeof(sattr_T));
Karsten Hopp 365b69
  #ifdef FEAT_MBYTE
Karsten Hopp 365b69
  	    if (enc_utf8)
Karsten Hopp 365b69
  	    {
Karsten Hopp 365b69
! 		mch_memmove(screenlineUC + r * Columns,
Karsten Hopp 365b69
  			    ScreenLinesUC + LineOffset[cmdline_row + r],
Karsten Hopp 365b69
! 			    (size_t)Columns * sizeof(u8char_T));
Karsten Hopp 365b69
  		for (i = 0; i < p_mco; ++i)
Karsten Hopp 365b69
! 		    mch_memmove(screenlineC[i] + r * Columns,
Karsten Hopp 365b69
! 				ScreenLinesC[r] + LineOffset[cmdline_row + r],
Karsten Hopp 365b69
! 				(size_t)Columns * sizeof(u8char_T));
Karsten Hopp 365b69
  	    }
Karsten Hopp 365b69
  	    if (enc_dbcs == DBCS_JPNU)
Karsten Hopp 365b69
! 		mch_memmove(screenline2 + r * Columns,
Karsten Hopp 365b69
  			    ScreenLines2 + LineOffset[cmdline_row + r],
Karsten Hopp 365b69
! 			    (size_t)Columns * sizeof(schar_T));
Karsten Hopp 365b69
  #endif
Karsten Hopp 365b69
  	}
Karsten Hopp 365b69
  
Karsten Hopp 365b69
--- 332,358 ----
Karsten Hopp 365b69
  	/* Save the text displayed in the command line area. */
Karsten Hopp 365b69
  	for (r = 0; r < rows; ++r)
Karsten Hopp 365b69
  	{
Karsten Hopp 365b69
! 	    mch_memmove(screenline + r * cols,
Karsten Hopp 365b69
  			ScreenLines + LineOffset[cmdline_row + r],
Karsten Hopp 365b69
! 			(size_t)cols * sizeof(schar_T));
Karsten Hopp 365b69
! 	    mch_memmove(screenattr + r * cols,
Karsten Hopp 365b69
  			ScreenAttrs + LineOffset[cmdline_row + r],
Karsten Hopp 365b69
! 			(size_t)cols * sizeof(sattr_T));
Karsten Hopp 365b69
  #ifdef FEAT_MBYTE
Karsten Hopp 365b69
  	    if (enc_utf8)
Karsten Hopp 365b69
  	    {
Karsten Hopp 365b69
! 		mch_memmove(screenlineUC + r * cols,
Karsten Hopp 365b69
  			    ScreenLinesUC + LineOffset[cmdline_row + r],
Karsten Hopp 365b69
! 			    (size_t)cols * sizeof(u8char_T));
Karsten Hopp 365b69
  		for (i = 0; i < p_mco; ++i)
Karsten Hopp 365b69
! 		    mch_memmove(screenlineC[i] + r * cols,
Karsten Hopp 365b69
! 				ScreenLinesC[i] + LineOffset[cmdline_row + r],
Karsten Hopp 365b69
! 				(size_t)cols * sizeof(u8char_T));
Karsten Hopp 365b69
  	    }
Karsten Hopp 365b69
  	    if (enc_dbcs == DBCS_JPNU)
Karsten Hopp 365b69
! 		mch_memmove(screenline2 + r * cols,
Karsten Hopp 365b69
  			    ScreenLines2 + LineOffset[cmdline_row + r],
Karsten Hopp 365b69
! 			    (size_t)cols * sizeof(schar_T));
Karsten Hopp 365b69
  #endif
Karsten Hopp 365b69
  	}
Karsten Hopp 365b69
  
Karsten Hopp 365b69
***************
Karsten Hopp 365b69
*** 366,393 ****
Karsten Hopp 365b69
  	    for (r = 0; r < rows; ++r)
Karsten Hopp 365b69
  	    {
Karsten Hopp 365b69
  		mch_memmove(current_ScreenLine,
Karsten Hopp 365b69
! 			    screenline + r * Columns,
Karsten Hopp 365b69
! 			    (size_t)Columns * sizeof(schar_T));
Karsten Hopp 365b69
  		mch_memmove(ScreenAttrs + off,
Karsten Hopp 365b69
! 			    screenattr + r * Columns,
Karsten Hopp 365b69
! 			    (size_t)Columns * sizeof(sattr_T));
Karsten Hopp 365b69
  #ifdef FEAT_MBYTE
Karsten Hopp 365b69
  		if (enc_utf8)
Karsten Hopp 365b69
  		{
Karsten Hopp 365b69
  		    mch_memmove(ScreenLinesUC + off,
Karsten Hopp 365b69
! 				screenlineUC + r * Columns,
Karsten Hopp 365b69
! 				(size_t)Columns * sizeof(u8char_T));
Karsten Hopp 365b69
  		    for (i = 0; i < p_mco; ++i)
Karsten Hopp 365b69
  			mch_memmove(ScreenLinesC[i] + off,
Karsten Hopp 365b69
! 				    screenlineC[i] + r * Columns,
Karsten Hopp 365b69
! 				    (size_t)Columns * sizeof(u8char_T));
Karsten Hopp 365b69
  		}
Karsten Hopp 365b69
  		if (enc_dbcs == DBCS_JPNU)
Karsten Hopp 365b69
  		    mch_memmove(ScreenLines2 + off,
Karsten Hopp 365b69
! 				screenline2 + r * Columns,
Karsten Hopp 365b69
! 				(size_t)Columns * sizeof(schar_T));
Karsten Hopp 365b69
  #endif
Karsten Hopp 365b69
! 		SCREEN_LINE(cmdline_row + r, 0, Columns, Columns, FALSE);
Karsten Hopp 365b69
  	    }
Karsten Hopp 365b69
  	    ret = 4;
Karsten Hopp 365b69
  	}
Karsten Hopp 365b69
--- 367,394 ----
Karsten Hopp 365b69
  	    for (r = 0; r < rows; ++r)
Karsten Hopp 365b69
  	    {
Karsten Hopp 365b69
  		mch_memmove(current_ScreenLine,
Karsten Hopp 365b69
! 			    screenline + r * cols,
Karsten Hopp 365b69
! 			    (size_t)cols * sizeof(schar_T));
Karsten Hopp 365b69
  		mch_memmove(ScreenAttrs + off,
Karsten Hopp 365b69
! 			    screenattr + r * cols,
Karsten Hopp 365b69
! 			    (size_t)cols * sizeof(sattr_T));
Karsten Hopp 365b69
  #ifdef FEAT_MBYTE
Karsten Hopp 365b69
  		if (enc_utf8)
Karsten Hopp 365b69
  		{
Karsten Hopp 365b69
  		    mch_memmove(ScreenLinesUC + off,
Karsten Hopp 365b69
! 				screenlineUC + r * cols,
Karsten Hopp 365b69
! 				(size_t)cols * sizeof(u8char_T));
Karsten Hopp 365b69
  		    for (i = 0; i < p_mco; ++i)
Karsten Hopp 365b69
  			mch_memmove(ScreenLinesC[i] + off,
Karsten Hopp 365b69
! 				    screenlineC[i] + r * cols,
Karsten Hopp 365b69
! 				    (size_t)cols * sizeof(u8char_T));
Karsten Hopp 365b69
  		}
Karsten Hopp 365b69
  		if (enc_dbcs == DBCS_JPNU)
Karsten Hopp 365b69
  		    mch_memmove(ScreenLines2 + off,
Karsten Hopp 365b69
! 				screenline2 + r * cols,
Karsten Hopp 365b69
! 				(size_t)cols * sizeof(schar_T));
Karsten Hopp 365b69
  #endif
Karsten Hopp 365b69
! 		SCREEN_LINE(cmdline_row + r, 0, cols, cols, FALSE);
Karsten Hopp 365b69
  	    }
Karsten Hopp 365b69
  	    ret = 4;
Karsten Hopp 365b69
  	}
Karsten Hopp 365b69
*** ../vim-7.4.796/src/version.c	2015-07-22 22:46:08.127010101 +0200
Karsten Hopp 365b69
--- src/version.c	2015-07-25 22:38:04.193354077 +0200
Karsten Hopp 365b69
***************
Karsten Hopp 365b69
*** 743,744 ****
Karsten Hopp 365b69
--- 743,746 ----
Karsten Hopp 365b69
  {   /* Add new patch number below this line */
Karsten Hopp 365b69
+ /**/
Karsten Hopp 365b69
+     797,
Karsten Hopp 365b69
  /**/
Karsten Hopp 365b69
Karsten Hopp 365b69
-- 
Karsten Hopp 365b69
Women are probably the main cause of free software starvation.
Karsten Hopp 365b69
Karsten Hopp 365b69
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 365b69
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 365b69
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 365b69
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///