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