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