From dffa5b8ecfa2091495b77ab487c07792646d0633 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Wed, 19 Nov 2014 16:38:07 +0100 Subject: updated for version 7.4.519 Problem: Crash when using syntax highlighting. Solution: When regprog is freed and replaced, store the result. --- src/syntax.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'src/syntax.c') diff --git a/src/syntax.c b/src/syntax.c index a93581018..fcd20c8ac 100644 --- a/src/syntax.c +++ b/src/syntax.c @@ -992,13 +992,16 @@ syn_match_linecont(lnum) linenr_T lnum; { regmmatch_T regmatch; + int r; if (syn_block->b_syn_linecont_prog != NULL) { regmatch.rmm_ic = syn_block->b_syn_linecont_ic; regmatch.regprog = syn_block->b_syn_linecont_prog; - return syn_regexec(®match, lnum, (colnr_T)0, + r = syn_regexec(®match, lnum, (colnr_T)0, IF_SYN_TIME(&syn_block->b_syn_linecont_time)); + syn_block->b_syn_linecont_prog = regmatch.regprog; + return r; } return FALSE; } @@ -2075,6 +2078,8 @@ syn_current_attr(syncing, displaying, can_spell, keep_state) cur_si->si_cont_list, &spp->sp_syn, spp->sp_flags & HL_CONTAINED)))) { + int r; + /* If we already tried matching in this line, and * there isn't a match before next_match_col, skip * this item. */ @@ -2089,10 +2094,12 @@ syn_current_attr(syncing, displaying, can_spell, keep_state) regmatch.rmm_ic = spp->sp_ic; regmatch.regprog = spp->sp_prog; - if (!syn_regexec(®match, + r = syn_regexec(®match, current_lnum, (colnr_T)lc_col, - IF_SYN_TIME(&spp->sp_time))) + IF_SYN_TIME(&spp->sp_time)); + spp->sp_prog = regmatch.regprog; + if (!r) { /* no match in this line, try another one */ spp->sp_startcol = MAXCOL; @@ -2963,6 +2970,7 @@ find_endpos(idx, startpos, m_endpos, hl_endpos, flagsp, end_endpos, for (idx = start_idx; idx < syn_block->b_syn_patterns.ga_len; ++idx) { int lc_col = matchcol; + int r; spp = &(SYN_ITEMS(syn_block)[idx]); if (spp->sp_type != SPTYPE_END) /* past last END pattern */ @@ -2973,8 +2981,10 @@ find_endpos(idx, startpos, m_endpos, hl_endpos, flagsp, end_endpos, regmatch.rmm_ic = spp->sp_ic; regmatch.regprog = spp->sp_prog; - if (syn_regexec(®match, startpos->lnum, lc_col, - IF_SYN_TIME(&spp->sp_time))) + r = syn_regexec(®match, startpos->lnum, lc_col, + IF_SYN_TIME(&spp->sp_time)); + spp->sp_prog = regmatch.regprog; + if (r) { if (best_idx == -1 || regmatch.startpos[0].col < best_regmatch.startpos[0].col) @@ -3000,14 +3010,16 @@ find_endpos(idx, startpos, m_endpos, hl_endpos, flagsp, end_endpos, if (spp_skip != NULL) { int lc_col = matchcol - spp_skip->sp_offsets[SPO_LC_OFF]; + int r; if (lc_col < 0) lc_col = 0; regmatch.rmm_ic = spp_skip->sp_ic; regmatch.regprog = spp_skip->sp_prog; - if (syn_regexec(®match, startpos->lnum, lc_col, - IF_SYN_TIME(&spp_skip->sp_time)) - && regmatch.startpos[0].col + r = syn_regexec(®match, startpos->lnum, lc_col, + IF_SYN_TIME(&spp_skip->sp_time)); + spp_skip->sp_prog = regmatch.regprog; + if (r && regmatch.startpos[0].col <= best_regmatch.startpos[0].col) { /* Add offset to skip pattern match */ -- cgit v1.2.1