Blob Blame History Raw
To: vim-dev@vim.org
Subject: patch 7.1.113
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
------------

Patch 7.1.113
Problem:    Using map() to go over an empty list causes memory to be freed
	    twice. (A.Politz)
Solution:   Don't clear the typeval in restore_vimvar().
Files:	    src/eval.c


*** ../vim-7.1.112/src/eval.c	Sun Sep 16 14:20:18 2007
--- src/eval.c	Sun Sep 16 19:24:49 2007
***************
*** 1318,1324 ****
  {
      hashitem_T	*hi;
  
-     clear_tv(&vimvars[idx].vv_tv);
      vimvars[idx].vv_tv = *save_tv;
      if (vimvars[idx].vv_type == VAR_UNKNOWN)
      {
--- 1318,1323 ----
***************
*** 1362,1368 ****
  
      if (p_verbose == 0)
  	--emsg_off;
-     vimvars[VV_VAL].vv_str = NULL;
      restore_vimvar(VV_VAL, &save_val);
  
      return list;
--- 1361,1366 ----
***************
*** 9387,9401 ****
  {
      typval_T	rettv;
      char_u	*s;
  
      copy_tv(tv, &vimvars[VV_VAL].vv_tv);
      s = expr;
      if (eval1(&s, &rettv, TRUE) == FAIL)
! 	return FAIL;
      if (*s != NUL)  /* check for trailing chars after expr */
      {
  	EMSG2(_(e_invexpr2), s);
! 	return FAIL;
      }
      if (map)
      {
--- 9386,9401 ----
  {
      typval_T	rettv;
      char_u	*s;
+     int		retval = FAIL;
  
      copy_tv(tv, &vimvars[VV_VAL].vv_tv);
      s = expr;
      if (eval1(&s, &rettv, TRUE) == FAIL)
! 	goto theend;
      if (*s != NUL)  /* check for trailing chars after expr */
      {
  	EMSG2(_(e_invexpr2), s);
! 	goto theend;
      }
      if (map)
      {
***************
*** 9414,9423 ****
  	/* On type error, nothing has been removed; return FAIL to stop the
  	 * loop.  The error message was given by get_tv_number_chk(). */
  	if (error)
! 	    return FAIL;
      }
      clear_tv(&vimvars[VV_VAL].vv_tv);
!     return OK;
  }
  
  /*
--- 9414,9425 ----
  	/* On type error, nothing has been removed; return FAIL to stop the
  	 * loop.  The error message was given by get_tv_number_chk(). */
  	if (error)
! 	    goto theend;
      }
+     retval = OK;
+ theend:
      clear_tv(&vimvars[VV_VAL].vv_tv);
!     return retval;
  }
  
  /*
*** ../vim-7.1.112/src/version.c	Sun Sep 16 14:20:18 2007
--- src/version.c	Mon Sep 17 21:33:52 2007
***************
*** 668,669 ****
--- 668,671 ----
  {   /* Add new patch number below this line */
+ /**/
+     113,
  /**/

-- 
Mental Floss prevents moral decay!

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///