Karsten Hopp 2fb512
To: vim_dev@googlegroups.com
Karsten Hopp 2fb512
Subject: Patch 7.3.1272
Karsten Hopp 2fb512
Fcc: outbox
Karsten Hopp 2fb512
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 2fb512
Mime-Version: 1.0
Karsten Hopp 2fb512
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 2fb512
Content-Transfer-Encoding: 8bit
Karsten Hopp 2fb512
------------
Karsten Hopp 2fb512
Karsten Hopp 2fb512
Patch 7.3.1272
Karsten Hopp 2fb512
Problem:    Crash when editing Ruby file. (Aliaksandr Rahalevich)
Karsten Hopp 2fb512
Solution:   Reallocate the state list when necessary.
Karsten Hopp 2fb512
Files:	    src/regexp_nfa.c
Karsten Hopp 2fb512
Karsten Hopp 2fb512
Karsten Hopp 2fb512
*** ../vim-7.3.1271/src/regexp_nfa.c	2013-06-28 23:04:38.000000000 +0200
Karsten Hopp 2fb512
--- src/regexp_nfa.c	2013-06-30 13:17:13.000000000 +0200
Karsten Hopp 2fb512
***************
Karsten Hopp 2fb512
*** 4228,4241 ****
Karsten Hopp 2fb512
      }
Karsten Hopp 2fb512
      else if (count > 1)
Karsten Hopp 2fb512
      {
Karsten Hopp 2fb512
! 	/* make space for new states, then move them from the
Karsten Hopp 2fb512
! 	 * end to the current position */
Karsten Hopp 2fb512
! 	mch_memmove(&(l->t[listidx + count]),
Karsten Hopp 2fb512
! 		&(l->t[listidx + 1]),
Karsten Hopp 2fb512
! 		sizeof(nfa_thread_T) * (l->n - listidx - 1));
Karsten Hopp 2fb512
! 	mch_memmove(&(l->t[listidx]),
Karsten Hopp 2fb512
! 		&(l->t[l->n - 1]),
Karsten Hopp 2fb512
! 		sizeof(nfa_thread_T) * count);
Karsten Hopp 2fb512
      }
Karsten Hopp 2fb512
      --l->n;
Karsten Hopp 2fb512
      *ip = listidx - 1;
Karsten Hopp 2fb512
--- 4228,4266 ----
Karsten Hopp 2fb512
      }
Karsten Hopp 2fb512
      else if (count > 1)
Karsten Hopp 2fb512
      {
Karsten Hopp 2fb512
! 	if (l->n + count - 1 >= l->len)
Karsten Hopp 2fb512
! 	{
Karsten Hopp 2fb512
! 	    /* not enough space to move the new states, reallocate the list
Karsten Hopp 2fb512
! 	     * and move the states to the right position */
Karsten Hopp 2fb512
! 	    nfa_thread_T *newl;
Karsten Hopp 2fb512
! 
Karsten Hopp 2fb512
! 	    l->len = l->len * 3 / 2 + 50;
Karsten Hopp 2fb512
! 	    newl = (nfa_thread_T *)alloc(l->len * sizeof(nfa_thread_T));
Karsten Hopp 2fb512
! 	    if (newl == NULL)
Karsten Hopp 2fb512
! 		return;
Karsten Hopp 2fb512
! 	    mch_memmove(&(newl[0]),
Karsten Hopp 2fb512
! 		    &(l->t[0]),
Karsten Hopp 2fb512
! 		    sizeof(nfa_thread_T) * listidx);
Karsten Hopp 2fb512
! 	    mch_memmove(&(newl[listidx]),
Karsten Hopp 2fb512
! 		    &(l->t[l->n - count]),
Karsten Hopp 2fb512
! 		    sizeof(nfa_thread_T) * count);
Karsten Hopp 2fb512
! 	    mch_memmove(&(newl[listidx + count]),
Karsten Hopp 2fb512
! 		    &(l->t[listidx + 1]),
Karsten Hopp 2fb512
! 		    sizeof(nfa_thread_T) * (l->n - count - listidx - 1));
Karsten Hopp 2fb512
! 	    vim_free(l->t);
Karsten Hopp 2fb512
! 	    l->t = newl;
Karsten Hopp 2fb512
! 	}
Karsten Hopp 2fb512
! 	else
Karsten Hopp 2fb512
! 	{
Karsten Hopp 2fb512
! 	    /* make space for new states, then move them from the
Karsten Hopp 2fb512
! 	     * end to the current position */
Karsten Hopp 2fb512
! 	    mch_memmove(&(l->t[listidx + count]),
Karsten Hopp 2fb512
! 		    &(l->t[listidx + 1]),
Karsten Hopp 2fb512
! 		    sizeof(nfa_thread_T) * (l->n - listidx - 1));
Karsten Hopp 2fb512
! 	    mch_memmove(&(l->t[listidx]),
Karsten Hopp 2fb512
! 		    &(l->t[l->n - 1]),
Karsten Hopp 2fb512
! 		    sizeof(nfa_thread_T) * count);
Karsten Hopp 2fb512
! 	}
Karsten Hopp 2fb512
      }
Karsten Hopp 2fb512
      --l->n;
Karsten Hopp 2fb512
      *ip = listidx - 1;
Karsten Hopp 2fb512
*** ../vim-7.3.1271/src/version.c	2013-06-30 12:21:18.000000000 +0200
Karsten Hopp 2fb512
--- src/version.c	2013-06-30 13:12:26.000000000 +0200
Karsten Hopp 2fb512
***************
Karsten Hopp 2fb512
*** 730,731 ****
Karsten Hopp 2fb512
--- 730,733 ----
Karsten Hopp 2fb512
  {   /* Add new patch number below this line */
Karsten Hopp 2fb512
+ /**/
Karsten Hopp 2fb512
+     1272,
Karsten Hopp 2fb512
  /**/
Karsten Hopp 2fb512
Karsten Hopp 2fb512
-- 
Karsten Hopp 2fb512
`When any government, or any church for that matter, undertakes to say to
Karsten Hopp 2fb512
 its subjects, "This you may not read, this you must not see, this you are
Karsten Hopp 2fb512
 forbidden to know," the end result is tyranny and oppression no matter how
Karsten Hopp 2fb512
 holy the motives' -- Robert A Heinlein, "If this goes on --"
Karsten Hopp 2fb512
Karsten Hopp 2fb512
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 2fb512
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 2fb512
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 2fb512
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///