To: vim-dev@vim.org
Subject: patch 7.1.086
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
------------
Patch 7.1.086
Problem: Crash when using specific Python syntax highlighting. (Quirk)
Solution: Check for a negative index, coming from a keyword match at the
start of a line from a saved state.
Files: src/syntax.c
*** ../vim-7.1.085/src/syntax.c Tue Aug 14 23:06:51 2007
--- src/syntax.c Tue Aug 21 17:13:51 2007
***************
*** 279,285 ****
*/
typedef struct state_item
{
! int si_idx; /* index of syntax pattern */
int si_id; /* highlight group ID for keywords */
int si_trans_id; /* idem, transparancy removed */
int si_m_lnum; /* lnum of the match */
--- 279,286 ----
*/
typedef struct state_item
{
! int si_idx; /* index of syntax pattern or
! KEYWORD_IDX */
int si_id; /* highlight group ID for keywords */
int si_trans_id; /* idem, transparancy removed */
int si_m_lnum; /* lnum of the match */
***************
*** 837,845 ****
current_lnum = end_lnum;
break;
}
! spp = &(SYN_ITEMS(syn_buf)[cur_si->si_idx]);
! found_flags = spp->sp_flags;
! found_match_idx = spp->sp_sync_idx;
found_current_lnum = current_lnum;
found_current_col = current_col;
found_m_endpos = cur_si->si_m_endpos;
--- 838,855 ----
current_lnum = end_lnum;
break;
}
! if (cur_si->si_idx < 0)
! {
! /* Cannot happen? */
! found_flags = 0;
! found_match_idx = KEYWORD_IDX;
! }
! else
! {
! spp = &(SYN_ITEMS(syn_buf)[cur_si->si_idx]);
! found_flags = spp->sp_flags;
! found_match_idx = spp->sp_sync_idx;
! }
found_current_lnum = current_lnum;
found_current_col = current_col;
found_m_endpos = cur_si->si_m_endpos;
***************
*** 2533,2538 ****
--- 2543,2552 ----
stateitem_T *sip = &CUR_STATE(idx);
synpat_T *spp;
+ /* This should not happen... */
+ if (sip->si_idx < 0)
+ return;
+
spp = &(SYN_ITEMS(syn_buf)[sip->si_idx]);
if (sip->si_flags & HL_MATCH)
sip->si_id = spp->sp_syn_match_id;
***************
*** 2648,2653 ****
--- 2662,2671 ----
lpos_T end_endpos;
int end_idx;
+ /* return quickly for a keyword */
+ if (sip->si_idx < 0)
+ return;
+
/* Don't update when it's already done. Can be a match of an end pattern
* that started in a previous line. Watch out: can also be a "keepend"
* from a containing item. */
***************
*** 2759,2764 ****
--- 2777,2786 ----
lpos_T pos;
char_u *line;
int had_match = FALSE;
+
+ /* just in case we are invoked for a keyword */
+ if (idx < 0)
+ return;
/*
* Check for being called with a START pattern.
*** ../vim-7.1.085/src/version.c Tue Aug 21 15:28:32 2007
--- src/version.c Tue Aug 21 17:21:06 2007
***************
*** 668,669 ****
--- 668,671 ----
{ /* Add new patch number below this line */
+ /**/
+ 86,
/**/
--
hundred-and-one symptoms of being an internet addict:
222. You send more than 20 personal e-mails a day.
/// 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 ///