Karsten Hopp e3acc4
To: vim-dev@vim.org
Karsten Hopp e3acc4
Subject: Patch 7.0.134
Karsten Hopp e3acc4
Fcc: outbox
Karsten Hopp e3acc4
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp e3acc4
Mime-Version: 1.0
Karsten Hopp e3acc4
Content-Type: text/plain; charset=ISO-8859-1
Karsten Hopp e3acc4
Content-Transfer-Encoding: 8bit
Karsten Hopp e3acc4
------------
Karsten Hopp e3acc4
Karsten Hopp e3acc4
Patch 7.0.134
Karsten Hopp e3acc4
Problem:    Crash when comparing a recursively looped List or Dictionary.
Karsten Hopp e3acc4
Solution:   Limit recursiveness for comparing to 1000.
Karsten Hopp e3acc4
Files:	    src/eval.c
Karsten Hopp e3acc4
Karsten Hopp e3acc4
Karsten Hopp e3acc4
*** ../vim-7.0.133/src/eval.c	Tue Oct 10 12:56:09 2006
Karsten Hopp e3acc4
--- src/eval.c	Sun Oct 15 15:08:13 2006
Karsten Hopp e3acc4
***************
Karsten Hopp e3acc4
*** 5520,5538 ****
Karsten Hopp e3acc4
  {
Karsten Hopp e3acc4
      char_u	buf1[NUMBUFLEN], buf2[NUMBUFLEN];
Karsten Hopp e3acc4
      char_u	*s1, *s2;
Karsten Hopp e3acc4
  
Karsten Hopp e3acc4
!     if (tv1->v_type != tv2->v_type)
Karsten Hopp e3acc4
  	return FALSE;
Karsten Hopp e3acc4
  
Karsten Hopp e3acc4
      switch (tv1->v_type)
Karsten Hopp e3acc4
      {
Karsten Hopp e3acc4
  	case VAR_LIST:
Karsten Hopp e3acc4
! 	    /* recursive! */
Karsten Hopp e3acc4
! 	    return list_equal(tv1->vval.v_list, tv2->vval.v_list, ic);
Karsten Hopp e3acc4
  
Karsten Hopp e3acc4
  	case VAR_DICT:
Karsten Hopp e3acc4
! 	    /* recursive! */
Karsten Hopp e3acc4
! 	    return dict_equal(tv1->vval.v_dict, tv2->vval.v_dict, ic);
Karsten Hopp e3acc4
  
Karsten Hopp e3acc4
  	case VAR_FUNC:
Karsten Hopp e3acc4
  	    return (tv1->vval.v_string != NULL
Karsten Hopp e3acc4
--- 5520,5546 ----
Karsten Hopp e3acc4
  {
Karsten Hopp e3acc4
      char_u	buf1[NUMBUFLEN], buf2[NUMBUFLEN];
Karsten Hopp e3acc4
      char_u	*s1, *s2;
Karsten Hopp e3acc4
+     static int  recursive = 0;	    /* cach recursive loops */
Karsten Hopp e3acc4
+     int		r;
Karsten Hopp e3acc4
  
Karsten Hopp e3acc4
!     /* Catch lists and dicts that have an endless loop by limiting
Karsten Hopp e3acc4
!      * recursiveness to 1000. */
Karsten Hopp e3acc4
!     if (tv1->v_type != tv2->v_type || recursive >= 1000)
Karsten Hopp e3acc4
  	return FALSE;
Karsten Hopp e3acc4
  
Karsten Hopp e3acc4
      switch (tv1->v_type)
Karsten Hopp e3acc4
      {
Karsten Hopp e3acc4
  	case VAR_LIST:
Karsten Hopp e3acc4
! 	    ++recursive;
Karsten Hopp e3acc4
! 	    r = list_equal(tv1->vval.v_list, tv2->vval.v_list, ic);
Karsten Hopp e3acc4
! 	    --recursive;
Karsten Hopp e3acc4
! 	    return r;
Karsten Hopp e3acc4
  
Karsten Hopp e3acc4
  	case VAR_DICT:
Karsten Hopp e3acc4
! 	    ++recursive;
Karsten Hopp e3acc4
! 	    r = dict_equal(tv1->vval.v_dict, tv2->vval.v_dict, ic);
Karsten Hopp e3acc4
! 	    --recursive;
Karsten Hopp e3acc4
! 	    return r;
Karsten Hopp e3acc4
  
Karsten Hopp e3acc4
  	case VAR_FUNC:
Karsten Hopp e3acc4
  	    return (tv1->vval.v_string != NULL
Karsten Hopp e3acc4
*** ../vim-7.0.133/src/version.c	Sat Oct 14 14:33:21 2006
Karsten Hopp e3acc4
--- src/version.c	Sun Oct 15 15:03:30 2006
Karsten Hopp e3acc4
***************
Karsten Hopp e3acc4
*** 668,669 ****
Karsten Hopp e3acc4
--- 668,671 ----
Karsten Hopp e3acc4
  {   /* Add new patch number below this line */
Karsten Hopp e3acc4
+ /**/
Karsten Hopp e3acc4
+     134,
Karsten Hopp e3acc4
  /**/
Karsten Hopp e3acc4
Karsten Hopp e3acc4
-- 
Karsten Hopp e3acc4
It was recently discovered that research causes cancer in rats.
Karsten Hopp e3acc4
Karsten Hopp e3acc4
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp e3acc4
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp e3acc4
\\\        download, build and distribute -- http://www.A-A-P.org        ///
Karsten Hopp e3acc4
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///