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