mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
updated for version 7.4.519
Problem: Crash when using syntax highlighting. Solution: When regprog is freed and replaced, store the result.
This commit is contained in:
28
src/syntax.c
28
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 */
|
||||
|
Reference in New Issue
Block a user