3f6673f
To: vim-dev@vim.org
3f6673f
Subject: patch 7.1.074
3f6673f
Fcc: outbox
3f6673f
From: Bram Moolenaar <Bram@moolenaar.net>
3f6673f
Mime-Version: 1.0
3f6673f
Content-Type: text/plain; charset=ISO-8859-1
3f6673f
Content-Transfer-Encoding: 8bit
3f6673f
------------
3f6673f
3f6673f
Patch 7.1.074
3f6673f
Problem:    Crash when calling string() on a recurively nested List.
3f6673f
Solution:   Check result value for being NULL. (Yukihiro Nakadaira)
3f6673f
Files:	    src/eval.c
3f6673f
3f6673f
3f6673f
*** ../vim-7.1.073/src/eval.c	Mon Aug  6 22:27:12 2007
3f6673f
--- src/eval.c	Tue Aug 14 22:01:12 2007
3f6673f
***************
3f6673f
*** 6802,6808 ****
3f6673f
   * "numbuf" is used for a number.
3f6673f
   * Does not put quotes around strings, as ":echo" displays values.
3f6673f
   * When "copyID" is not NULL replace recursive lists and dicts with "...".
3f6673f
!  * May return NULL;
3f6673f
   */
3f6673f
      static char_u *
3f6673f
  echo_string(tv, tofree, numbuf, copyID)
3f6673f
--- 6802,6808 ----
3f6673f
   * "numbuf" is used for a number.
3f6673f
   * Does not put quotes around strings, as ":echo" displays values.
3f6673f
   * When "copyID" is not NULL replace recursive lists and dicts with "...".
3f6673f
!  * May return NULL.
3f6673f
   */
3f6673f
      static char_u *
3f6673f
  echo_string(tv, tofree, numbuf, copyID)
3f6673f
***************
3f6673f
*** 6887,6893 ****
3f6673f
   * If the memory is allocated "tofree" is set to it, otherwise NULL.
3f6673f
   * "numbuf" is used for a number.
3f6673f
   * Puts quotes around strings, so that they can be parsed back by eval().
3f6673f
!  * May return NULL;
3f6673f
   */
3f6673f
      static char_u *
3f6673f
  tv2string(tv, tofree, numbuf, copyID)
3f6673f
--- 6887,6893 ----
3f6673f
   * If the memory is allocated "tofree" is set to it, otherwise NULL.
3f6673f
   * "numbuf" is used for a number.
3f6673f
   * Puts quotes around strings, so that they can be parsed back by eval().
3f6673f
!  * May return NULL.
3f6673f
   */
3f6673f
      static char_u *
3f6673f
  tv2string(tv, tofree, numbuf, copyID)
3f6673f
***************
3f6673f
*** 14974,14979 ****
3f6673f
--- 14974,14983 ----
3f6673f
  
3f6673f
      p1 = tv2string(&(*(listitem_T **)s1)->li_tv, &tofree1, numbuf1, 0);
3f6673f
      p2 = tv2string(&(*(listitem_T **)s2)->li_tv, &tofree2, numbuf2, 0);
3f6673f
+     if (p1 == NULL)
3f6673f
+ 	p1 = (char_u *)"";
3f6673f
+     if (p2 == NULL)
3f6673f
+ 	p2 = (char_u *)"";
3f6673f
      if (item_compare_ic)
3f6673f
  	res = STRICMP(p1, p2);
3f6673f
      else
3f6673f
***************
3f6673f
*** 15463,15469 ****
3f6673f
  
3f6673f
      rettv->v_type = VAR_STRING;
3f6673f
      rettv->vval.v_string = tv2string(&argvars[0], &tofree, numbuf, 0);
3f6673f
!     if (tofree == NULL)
3f6673f
  	rettv->vval.v_string = vim_strsave(rettv->vval.v_string);
3f6673f
  }
3f6673f
  
3f6673f
--- 15467,15474 ----
3f6673f
  
3f6673f
      rettv->v_type = VAR_STRING;
3f6673f
      rettv->vval.v_string = tv2string(&argvars[0], &tofree, numbuf, 0);
3f6673f
!     /* Make a copy if we have a value but it's not in allocate memory. */
3f6673f
!     if (rettv->vval.v_string != NULL && tofree == NULL)
3f6673f
  	rettv->vval.v_string = vim_strsave(rettv->vval.v_string);
3f6673f
  }
3f6673f
  
3f6673f
***************
3f6673f
*** 20167,20172 ****
3f6673f
--- 20174,20180 ----
3f6673f
  		char_u	buf[MSG_BUF_LEN];
3f6673f
  		char_u	numbuf2[NUMBUFLEN];
3f6673f
  		char_u	*tofree;
3f6673f
+ 		char_u	*s;
3f6673f
  
3f6673f
  		msg_puts((char_u *)"(");
3f6673f
  		for (i = 0; i < argcount; ++i)
3f6673f
***************
3f6673f
*** 20177,20186 ****
3f6673f
  			msg_outnum((long)argvars[i].vval.v_number);
3f6673f
  		    else
3f6673f
  		    {
3f6673f
! 			trunc_string(tv2string(&argvars[i], &tofree,
3f6673f
! 					      numbuf2, 0), buf, MSG_BUF_CLEN);
3f6673f
! 			msg_puts(buf);
3f6673f
! 			vim_free(tofree);
3f6673f
  		    }
3f6673f
  		}
3f6673f
  		msg_puts((char_u *)")");
3f6673f
--- 20185,20197 ----
3f6673f
  			msg_outnum((long)argvars[i].vval.v_number);
3f6673f
  		    else
3f6673f
  		    {
3f6673f
! 			s = tv2string(&argvars[i], &tofree, numbuf2, 0);
3f6673f
! 			if (s != NULL)
3f6673f
! 			{
3f6673f
! 			    trunc_string(s, buf, MSG_BUF_CLEN);
3f6673f
! 			    msg_puts(buf);
3f6673f
! 			    vim_free(tofree);
3f6673f
! 			}
3f6673f
  		    }
3f6673f
  		}
3f6673f
  		msg_puts((char_u *)")");
3f6673f
***************
3f6673f
*** 20258,20271 ****
3f6673f
  	    char_u	buf[MSG_BUF_LEN];
3f6673f
  	    char_u	numbuf2[NUMBUFLEN];
3f6673f
  	    char_u	*tofree;
3f6673f
  
3f6673f
  	    /* The value may be very long.  Skip the middle part, so that we
3f6673f
  	     * have some idea how it starts and ends. smsg() would always
3f6673f
  	     * truncate it at the end. */
3f6673f
! 	    trunc_string(tv2string(fc.rettv, &tofree, numbuf2, 0),
3f6673f
! 							   buf, MSG_BUF_CLEN);
3f6673f
! 	    smsg((char_u *)_("%s returning %s"), sourcing_name, buf);
3f6673f
! 	    vim_free(tofree);
3f6673f
  	}
3f6673f
  	msg_puts((char_u *)"\n");   /* don't overwrite this either */
3f6673f
  
3f6673f
--- 20269,20286 ----
3f6673f
  	    char_u	buf[MSG_BUF_LEN];
3f6673f
  	    char_u	numbuf2[NUMBUFLEN];
3f6673f
  	    char_u	*tofree;
3f6673f
+ 	    char_u	*s;
3f6673f
  
3f6673f
  	    /* The value may be very long.  Skip the middle part, so that we
3f6673f
  	     * have some idea how it starts and ends. smsg() would always
3f6673f
  	     * truncate it at the end. */
3f6673f
! 	    s = tv2string(fc.rettv, &tofree, numbuf2, 0);
3f6673f
! 	    if (s != NULL)
3f6673f
! 	    {
3f6673f
! 		trunc_string(s, buf, MSG_BUF_CLEN);
3f6673f
! 		smsg((char_u *)_("%s returning %s"), sourcing_name, buf);
3f6673f
! 		vim_free(tofree);
3f6673f
! 	    }
3f6673f
  	}
3f6673f
  	msg_puts((char_u *)"\n");   /* don't overwrite this either */
3f6673f
  
3f6673f
*** ../vim-7.1.073/src/version.c	Tue Aug 14 22:15:53 2007
3f6673f
--- src/version.c	Tue Aug 14 22:27:24 2007
3f6673f
***************
3f6673f
*** 668,669 ****
3f6673f
--- 668,671 ----
3f6673f
  {   /* Add new patch number below this line */
3f6673f
+ /**/
3f6673f
+     74,
3f6673f
  /**/
3f6673f
3f6673f
-- 
3f6673f
hundred-and-one symptoms of being an internet addict:
3f6673f
159. You get excited whenever discussing your hard drive.
3f6673f
3f6673f
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
3f6673f
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
3f6673f
\\\        download, build and distribute -- http://www.A-A-P.org        ///
3f6673f
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///