Karsten Hopp 3943c2
To: vim-dev@vim.org
Karsten Hopp 3943c2
Subject: Patch 7.2.113
Karsten Hopp 3943c2
Fcc: outbox
Karsten Hopp 3943c2
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 3943c2
Mime-Version: 1.0
Karsten Hopp 3943c2
Content-Type: text/plain; charset=ISO-8859-1
Karsten Hopp 3943c2
Content-Transfer-Encoding: 8bit
Karsten Hopp 3943c2
------------
Karsten Hopp 3943c2
Karsten Hopp 3943c2
Patch 7.2.113
Karsten Hopp 3943c2
Problem:    Crash for substitute() call using submatch(1) while there is no
Karsten Hopp 3943c2
            such submatch. (Yukihiro Nakadaira)
Karsten Hopp 3943c2
Solution:   Also check the start of the submatch is set, it can be NULL when
Karsten Hopp 3943c2
            an attempted match didn't work out.
Karsten Hopp 3943c2
Files:      src/regexp.c
Karsten Hopp 3943c2
Karsten Hopp 3943c2
Karsten Hopp 3943c2
*** ../vim-7.2.112/src/regexp.c	Fri Aug  8 13:45:31 2008
Karsten Hopp 3943c2
--- src/regexp.c	Sat Feb 21 21:46:49 2009
Karsten Hopp 3943c2
***************
Karsten Hopp 3943c2
*** 4532,4538 ****
Karsten Hopp 3943c2
  		cleanup_subexpr();
Karsten Hopp 3943c2
  		if (!REG_MULTI)		/* Single-line regexp */
Karsten Hopp 3943c2
  		{
Karsten Hopp 3943c2
! 		    if (reg_endp[no] == NULL)
Karsten Hopp 3943c2
  		    {
Karsten Hopp 3943c2
  			/* Backref was not set: Match an empty string. */
Karsten Hopp 3943c2
  			len = 0;
Karsten Hopp 3943c2
--- 4532,4538 ----
Karsten Hopp 3943c2
  		cleanup_subexpr();
Karsten Hopp 3943c2
  		if (!REG_MULTI)		/* Single-line regexp */
Karsten Hopp 3943c2
  		{
Karsten Hopp 3943c2
! 		    if (reg_startp[no] == NULL || reg_endp[no] == NULL)
Karsten Hopp 3943c2
  		    {
Karsten Hopp 3943c2
  			/* Backref was not set: Match an empty string. */
Karsten Hopp 3943c2
  			len = 0;
Karsten Hopp 3943c2
***************
Karsten Hopp 3943c2
*** 4548,4554 ****
Karsten Hopp 3943c2
  		}
Karsten Hopp 3943c2
  		else				/* Multi-line regexp */
Karsten Hopp 3943c2
  		{
Karsten Hopp 3943c2
! 		    if (reg_endpos[no].lnum < 0)
Karsten Hopp 3943c2
  		    {
Karsten Hopp 3943c2
  			/* Backref was not set: Match an empty string. */
Karsten Hopp 3943c2
  			len = 0;
Karsten Hopp 3943c2
--- 4548,4554 ----
Karsten Hopp 3943c2
  		}
Karsten Hopp 3943c2
  		else				/* Multi-line regexp */
Karsten Hopp 3943c2
  		{
Karsten Hopp 3943c2
! 		    if (reg_startpos[no].lnum < 0 || reg_endpos[no].lnum < 0)
Karsten Hopp 3943c2
  		    {
Karsten Hopp 3943c2
  			/* Backref was not set: Match an empty string. */
Karsten Hopp 3943c2
  			len = 0;
Karsten Hopp 3943c2
***************
Karsten Hopp 3943c2
*** 7279,7291 ****
Karsten Hopp 3943c2
      }
Karsten Hopp 3943c2
      else
Karsten Hopp 3943c2
      {
Karsten Hopp 3943c2
! 	if (submatch_match->endp[no] == NULL)
Karsten Hopp 3943c2
  	    retval = NULL;
Karsten Hopp 3943c2
  	else
Karsten Hopp 3943c2
- 	{
Karsten Hopp 3943c2
- 	    s = submatch_match->startp[no];
Karsten Hopp 3943c2
  	    retval = vim_strnsave(s, (int)(submatch_match->endp[no] - s));
Karsten Hopp 3943c2
- 	}
Karsten Hopp 3943c2
      }
Karsten Hopp 3943c2
  
Karsten Hopp 3943c2
      return retval;
Karsten Hopp 3943c2
--- 7279,7289 ----
Karsten Hopp 3943c2
      }
Karsten Hopp 3943c2
      else
Karsten Hopp 3943c2
      {
Karsten Hopp 3943c2
! 	s = submatch_match->startp[no];
Karsten Hopp 3943c2
! 	if (s == NULL || submatch_match->endp[no] == NULL)
Karsten Hopp 3943c2
  	    retval = NULL;
Karsten Hopp 3943c2
  	else
Karsten Hopp 3943c2
  	    retval = vim_strnsave(s, (int)(submatch_match->endp[no] - s));
Karsten Hopp 3943c2
      }
Karsten Hopp 3943c2
  
Karsten Hopp 3943c2
      return retval;
Karsten Hopp 3943c2
*** ../vim-7.2.112/src/version.c	Sat Feb 21 21:22:44 2009
Karsten Hopp 3943c2
--- src/version.c	Sat Feb 21 22:01:56 2009
Karsten Hopp 3943c2
***************
Karsten Hopp 3943c2
*** 678,679 ****
Karsten Hopp 3943c2
--- 678,681 ----
Karsten Hopp 3943c2
  {   /* Add new patch number below this line */
Karsten Hopp 3943c2
+ /**/
Karsten Hopp 3943c2
+     113,
Karsten Hopp 3943c2
  /**/
Karsten Hopp 3943c2
Karsten Hopp 3943c2
-- 
Karsten Hopp 3943c2
hundred-and-one symptoms of being an internet addict:
Karsten Hopp 3943c2
103. When you find yourself in the "Computer" section of Barnes & Noble
Karsten Hopp 3943c2
     enjoying yourself.
Karsten Hopp 3943c2
Karsten Hopp 3943c2
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 3943c2
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 3943c2
\\\        download, build and distribute -- http://www.A-A-P.org        ///
Karsten Hopp 3943c2
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///