Karsten Hopp da4c0c
To: vim-dev@vim.org
Karsten Hopp da4c0c
Subject: Patch 7.2.273
Karsten Hopp da4c0c
Fcc: outbox
Karsten Hopp da4c0c
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp da4c0c
Mime-Version: 1.0
Karsten Hopp da4c0c
Content-Type: text/plain; charset=UTF-8
Karsten Hopp da4c0c
Content-Transfer-Encoding: 8bit
Karsten Hopp da4c0c
------------
Karsten Hopp da4c0c
Karsten Hopp da4c0c
Patch 7.2.273
Karsten Hopp da4c0c
Problem:    Crash with redir to unknown array. (Christian Brabandt)
Karsten Hopp da4c0c
Solution:   Don't assign the redir result when there was an error.
Karsten Hopp da4c0c
Files:	    src/eval.c
Karsten Hopp da4c0c
Karsten Hopp da4c0c
Karsten Hopp da4c0c
*** ../vim-7.2.272/src/eval.c	2009-09-30 15:15:33.000000000 +0200
Karsten Hopp da4c0c
--- src/eval.c	2009-11-03 12:05:07.000000000 +0100
Karsten Hopp da4c0c
***************
Karsten Hopp da4c0c
*** 988,1000 ****
Karsten Hopp da4c0c
      int		err;
Karsten Hopp da4c0c
      typval_T	tv;
Karsten Hopp da4c0c
  
Karsten Hopp da4c0c
!     /* Make sure a valid variable name is specified */
Karsten Hopp da4c0c
      if (!eval_isnamec1(*name))
Karsten Hopp da4c0c
      {
Karsten Hopp da4c0c
  	EMSG(_(e_invarg));
Karsten Hopp da4c0c
  	return FAIL;
Karsten Hopp da4c0c
      }
Karsten Hopp da4c0c
  
Karsten Hopp da4c0c
      redir_varname = vim_strsave(name);
Karsten Hopp da4c0c
      if (redir_varname == NULL)
Karsten Hopp da4c0c
  	return FAIL;
Karsten Hopp da4c0c
--- 988,1001 ----
Karsten Hopp da4c0c
      int		err;
Karsten Hopp da4c0c
      typval_T	tv;
Karsten Hopp da4c0c
  
Karsten Hopp da4c0c
!     /* Catch a bad name early. */
Karsten Hopp da4c0c
      if (!eval_isnamec1(*name))
Karsten Hopp da4c0c
      {
Karsten Hopp da4c0c
  	EMSG(_(e_invarg));
Karsten Hopp da4c0c
  	return FAIL;
Karsten Hopp da4c0c
      }
Karsten Hopp da4c0c
  
Karsten Hopp da4c0c
+     /* Make a copy of the name, it is used in redir_lval until redir ends. */
Karsten Hopp da4c0c
      redir_varname = vim_strsave(name);
Karsten Hopp da4c0c
      if (redir_varname == NULL)
Karsten Hopp da4c0c
  	return FAIL;
Karsten Hopp da4c0c
***************
Karsten Hopp da4c0c
*** 1019,1024 ****
Karsten Hopp da4c0c
--- 1020,1026 ----
Karsten Hopp da4c0c
  	    EMSG(_(e_trailing));
Karsten Hopp da4c0c
  	else
Karsten Hopp da4c0c
  	    EMSG(_(e_invarg));
Karsten Hopp da4c0c
+ 	redir_endp = NULL;  /* don't store a value, only cleanup */
Karsten Hopp da4c0c
  	var_redir_stop();
Karsten Hopp da4c0c
  	return FAIL;
Karsten Hopp da4c0c
      }
Karsten Hopp da4c0c
***************
Karsten Hopp da4c0c
*** 1037,1042 ****
Karsten Hopp da4c0c
--- 1039,1045 ----
Karsten Hopp da4c0c
      did_emsg |= save_emsg;
Karsten Hopp da4c0c
      if (err)
Karsten Hopp da4c0c
      {
Karsten Hopp da4c0c
+ 	redir_endp = NULL;  /* don't store a value, only cleanup */
Karsten Hopp da4c0c
  	var_redir_stop();
Karsten Hopp da4c0c
  	return FAIL;
Karsten Hopp da4c0c
      }
Karsten Hopp da4c0c
***************
Karsten Hopp da4c0c
*** 1085,1090 ****
Karsten Hopp da4c0c
--- 1088,1094 ----
Karsten Hopp da4c0c
  
Karsten Hopp da4c0c
  /*
Karsten Hopp da4c0c
   * Stop redirecting command output to a variable.
Karsten Hopp da4c0c
+  * Frees the allocated memory.
Karsten Hopp da4c0c
   */
Karsten Hopp da4c0c
      void
Karsten Hopp da4c0c
  var_redir_stop()
Karsten Hopp da4c0c
***************
Karsten Hopp da4c0c
*** 1093,1106 ****
Karsten Hopp da4c0c
  
Karsten Hopp da4c0c
      if (redir_lval != NULL)
Karsten Hopp da4c0c
      {
Karsten Hopp da4c0c
! 	/* Append the trailing NUL. */
Karsten Hopp da4c0c
! 	ga_append(&redir_ga, NUL);
Karsten Hopp da4c0c
  
Karsten Hopp da4c0c
! 	/* Assign the text to the variable. */
Karsten Hopp da4c0c
! 	tv.v_type = VAR_STRING;
Karsten Hopp da4c0c
! 	tv.vval.v_string = redir_ga.ga_data;
Karsten Hopp da4c0c
! 	set_var_lval(redir_lval, redir_endp, &tv, FALSE, (char_u *)".");
Karsten Hopp da4c0c
! 	vim_free(tv.vval.v_string);
Karsten Hopp da4c0c
  
Karsten Hopp da4c0c
  	clear_lval(redir_lval);
Karsten Hopp da4c0c
  	vim_free(redir_lval);
Karsten Hopp da4c0c
--- 1097,1114 ----
Karsten Hopp da4c0c
  
Karsten Hopp da4c0c
      if (redir_lval != NULL)
Karsten Hopp da4c0c
      {
Karsten Hopp da4c0c
! 	/* If there was no error: assign the text to the variable. */
Karsten Hopp da4c0c
! 	if (redir_endp != NULL)
Karsten Hopp da4c0c
! 	{
Karsten Hopp da4c0c
! 	    ga_append(&redir_ga, NUL);  /* Append the trailing NUL. */
Karsten Hopp da4c0c
! 	    tv.v_type = VAR_STRING;
Karsten Hopp da4c0c
! 	    tv.vval.v_string = redir_ga.ga_data;
Karsten Hopp da4c0c
! 	    set_var_lval(redir_lval, redir_endp, &tv, FALSE, (char_u *)".");
Karsten Hopp da4c0c
! 	}
Karsten Hopp da4c0c
  
Karsten Hopp da4c0c
! 	/* free the collected output */
Karsten Hopp da4c0c
! 	vim_free(redir_ga.ga_data);
Karsten Hopp da4c0c
! 	redir_ga.ga_data = NULL;
Karsten Hopp da4c0c
  
Karsten Hopp da4c0c
  	clear_lval(redir_lval);
Karsten Hopp da4c0c
  	vim_free(redir_lval);
Karsten Hopp da4c0c
*** ../vim-7.2.272/src/version.c	2009-11-03 13:06:03.000000000 +0100
Karsten Hopp da4c0c
--- src/version.c	2009-11-03 14:24:06.000000000 +0100
Karsten Hopp da4c0c
***************
Karsten Hopp da4c0c
*** 678,679 ****
Karsten Hopp da4c0c
--- 678,681 ----
Karsten Hopp da4c0c
  {   /* Add new patch number below this line */
Karsten Hopp da4c0c
+ /**/
Karsten Hopp da4c0c
+     273,
Karsten Hopp da4c0c
  /**/
Karsten Hopp da4c0c
Karsten Hopp da4c0c
-- 
Karsten Hopp da4c0c
Permission is granted to read this message out aloud on Kings Cross Road,
Karsten Hopp da4c0c
London, under the condition that the orator is properly dressed.
Karsten Hopp da4c0c
Karsten Hopp da4c0c
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp da4c0c
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp da4c0c
\\\        download, build and distribute -- http://www.A-A-P.org        ///
Karsten Hopp da4c0c
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///