Karsten Hopp 569135
To: vim-dev@vim.org
Karsten Hopp 569135
Subject: Patch 7.0.021
Karsten Hopp 569135
Fcc: outbox
Karsten Hopp 569135
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 569135
Mime-Version: 1.0
Karsten Hopp 569135
Content-Type: text/plain; charset=ISO-8859-1
Karsten Hopp 569135
Content-Transfer-Encoding: 8bit
Karsten Hopp 569135
------------
Karsten Hopp 569135
Karsten Hopp 569135
Patch 7.0.021
Karsten Hopp 569135
Problem:    Crash when using "\\[" and "\\]" in 'errorformat'. (Marc Weber)
Karsten Hopp 569135
Solution:   Check for valid submatches after matching the pattern.
Karsten Hopp 569135
Files:      src/quickfix.c
Karsten Hopp 569135
Karsten Hopp 569135
Karsten Hopp 569135
*** ../vim-7.0.020/src/quickfix.c	Wed May  3 23:23:30 2006
Karsten Hopp 569135
--- src/quickfix.c	Tue Jun 20 17:04:20 2006
Karsten Hopp 569135
***************
Karsten Hopp 569135
*** 602,614 ****
Karsten Hopp 569135
  		else
Karsten Hopp 569135
  		    type = 0;
Karsten Hopp 569135
  		/*
Karsten Hopp 569135
! 		 * Extract error message data from matched line
Karsten Hopp 569135
  		 */
Karsten Hopp 569135
  		if ((i = (int)fmt_ptr->addr[0]) > 0)		/* %f */
Karsten Hopp 569135
  		{
Karsten Hopp 569135
! 		    int c = *regmatch.endp[i];
Karsten Hopp 569135
  
Karsten Hopp 569135
  		    /* Expand ~/file and $HOME/file to full path. */
Karsten Hopp 569135
  		    *regmatch.endp[i] = NUL;
Karsten Hopp 569135
  		    expand_env(regmatch.startp[i], namebuf, CMDBUFFSIZE);
Karsten Hopp 569135
  		    *regmatch.endp[i] = c;
Karsten Hopp 569135
--- 602,620 ----
Karsten Hopp 569135
  		else
Karsten Hopp 569135
  		    type = 0;
Karsten Hopp 569135
  		/*
Karsten Hopp 569135
! 		 * Extract error message data from matched line.
Karsten Hopp 569135
! 		 * We check for an actual submatch, because "\[" and "\]" in
Karsten Hopp 569135
! 		 * the 'errorformat' may cause the wrong submatch to be used.
Karsten Hopp 569135
  		 */
Karsten Hopp 569135
  		if ((i = (int)fmt_ptr->addr[0]) > 0)		/* %f */
Karsten Hopp 569135
  		{
Karsten Hopp 569135
! 		    int c;
Karsten Hopp 569135
! 
Karsten Hopp 569135
! 		    if (regmatch.startp[i] == NULL || regmatch.endp[i] == NULL)
Karsten Hopp 569135
! 			continue;
Karsten Hopp 569135
  
Karsten Hopp 569135
  		    /* Expand ~/file and $HOME/file to full path. */
Karsten Hopp 569135
+ 		    c = *regmatch.endp[i];
Karsten Hopp 569135
  		    *regmatch.endp[i] = NUL;
Karsten Hopp 569135
  		    expand_env(regmatch.startp[i], namebuf, CMDBUFFSIZE);
Karsten Hopp 569135
  		    *regmatch.endp[i] = c;
Karsten Hopp 569135
***************
Karsten Hopp 569135
*** 618,652 ****
Karsten Hopp 569135
--- 624,686 ----
Karsten Hopp 569135
  			continue;
Karsten Hopp 569135
  		}
Karsten Hopp 569135
  		if ((i = (int)fmt_ptr->addr[1]) > 0)		/* %n */
Karsten Hopp 569135
+ 		{
Karsten Hopp 569135
+ 		    if (regmatch.startp[i] == NULL)
Karsten Hopp 569135
+ 			continue;
Karsten Hopp 569135
  		    enr = (int)atol((char *)regmatch.startp[i]);
Karsten Hopp 569135
+ 		}
Karsten Hopp 569135
  		if ((i = (int)fmt_ptr->addr[2]) > 0)		/* %l */
Karsten Hopp 569135
+ 		{
Karsten Hopp 569135
+ 		    if (regmatch.startp[i] == NULL)
Karsten Hopp 569135
+ 			continue;
Karsten Hopp 569135
  		    lnum = atol((char *)regmatch.startp[i]);
Karsten Hopp 569135
+ 		}
Karsten Hopp 569135
  		if ((i = (int)fmt_ptr->addr[3]) > 0)		/* %c */
Karsten Hopp 569135
+ 		{
Karsten Hopp 569135
+ 		    if (regmatch.startp[i] == NULL)
Karsten Hopp 569135
+ 			continue;
Karsten Hopp 569135
  		    col = (int)atol((char *)regmatch.startp[i]);
Karsten Hopp 569135
+ 		}
Karsten Hopp 569135
  		if ((i = (int)fmt_ptr->addr[4]) > 0)		/* %t */
Karsten Hopp 569135
+ 		{
Karsten Hopp 569135
+ 		    if (regmatch.startp[i] == NULL)
Karsten Hopp 569135
+ 			continue;
Karsten Hopp 569135
  		    type = *regmatch.startp[i];
Karsten Hopp 569135
+ 		}
Karsten Hopp 569135
  		if (fmt_ptr->flags == '+' && !multiscan)	/* %+ */
Karsten Hopp 569135
  		    STRCPY(errmsg, IObuff);
Karsten Hopp 569135
  		else if ((i = (int)fmt_ptr->addr[5]) > 0)	/* %m */
Karsten Hopp 569135
  		{
Karsten Hopp 569135
+ 		    if (regmatch.startp[i] == NULL || regmatch.endp[i] == NULL)
Karsten Hopp 569135
+ 			continue;
Karsten Hopp 569135
  		    len = (int)(regmatch.endp[i] - regmatch.startp[i]);
Karsten Hopp 569135
  		    vim_strncpy(errmsg, regmatch.startp[i], len);
Karsten Hopp 569135
  		}
Karsten Hopp 569135
  		if ((i = (int)fmt_ptr->addr[6]) > 0)		/* %r */
Karsten Hopp 569135
+ 		{
Karsten Hopp 569135
+ 		    if (regmatch.startp[i] == NULL)
Karsten Hopp 569135
+ 			continue;
Karsten Hopp 569135
  		    tail = regmatch.startp[i];
Karsten Hopp 569135
+ 		}
Karsten Hopp 569135
  		if ((i = (int)fmt_ptr->addr[7]) > 0)		/* %p */
Karsten Hopp 569135
  		{
Karsten Hopp 569135
+ 		    if (regmatch.startp[i] == NULL || regmatch.endp[i] == NULL)
Karsten Hopp 569135
+ 			continue;
Karsten Hopp 569135
  		    col = (int)(regmatch.endp[i] - regmatch.startp[i] + 1);
Karsten Hopp 569135
  		    if (*((char_u *)regmatch.startp[i]) != TAB)
Karsten Hopp 569135
  			use_viscol = TRUE;
Karsten Hopp 569135
  		}
Karsten Hopp 569135
  		if ((i = (int)fmt_ptr->addr[8]) > 0)		/* %v */
Karsten Hopp 569135
  		{
Karsten Hopp 569135
+ 		    if (regmatch.startp[i] == NULL)
Karsten Hopp 569135
+ 			continue;
Karsten Hopp 569135
  		    col = (int)atol((char *)regmatch.startp[i]);
Karsten Hopp 569135
  		    use_viscol = TRUE;
Karsten Hopp 569135
  		}
Karsten Hopp 569135
  		if ((i = (int)fmt_ptr->addr[9]) > 0)		/* %s */
Karsten Hopp 569135
  		{
Karsten Hopp 569135
+ 		    if (regmatch.startp[i] == NULL || regmatch.endp[i] == NULL)
Karsten Hopp 569135
+ 			continue;
Karsten Hopp 569135
  		    len = (int)(regmatch.endp[i] - regmatch.startp[i]);
Karsten Hopp 569135
  		    if (len > CMDBUFFSIZE - 5)
Karsten Hopp 569135
  			len = CMDBUFFSIZE - 5;
Karsten Hopp 569135
*** ../vim-7.0.020/src/version.c	Tue Jun 20 16:33:21 2006
Karsten Hopp 569135
--- src/version.c	Tue Jun 20 17:07:25 2006
Karsten Hopp 569135
***************
Karsten Hopp 569135
*** 668,669 ****
Karsten Hopp 569135
--- 668,671 ----
Karsten Hopp 569135
  {   /* Add new patch number below this line */
Karsten Hopp 569135
+ /**/
Karsten Hopp 569135
+     21,
Karsten Hopp 569135
  /**/
Karsten Hopp 569135
Karsten Hopp 569135
-- 
Karsten Hopp 569135
TALL KNIGHT: We are now no longer the Knights Who Say Ni!
Karsten Hopp 569135
ONE KNIGHT:  Ni!
Karsten Hopp 569135
OTHERS:      Sh!
Karsten Hopp 569135
ONE KNIGHT:  (whispers) Sorry.
Karsten Hopp 569135
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
Karsten Hopp 569135
Karsten Hopp 569135
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 569135
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 569135
\\\        download, build and distribute -- http://www.A-A-P.org        ///
Karsten Hopp 569135
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///