summaryrefslogtreecommitdiff
path: root/src/syntax.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2014-11-19 16:38:07 +0100
committerBram Moolenaar <Bram@vim.org>2014-11-19 16:38:07 +0100
commitdffa5b8ecfa2091495b77ab487c07792646d0633 (patch)
tree9f9ccaac14e2fffceec8ee02ac7e6590de1c226b /src/syntax.c
parentdf46f6f07f90c0014352ff05aecb8caf61e7cfa0 (diff)
downloadvim-git-dffa5b8ecfa2091495b77ab487c07792646d0633.tar.gz
updated for version 7.4.519v7.4.519
Problem: Crash when using syntax highlighting. Solution: When regprog is freed and replaced, store the result.
Diffstat (limited to 'src/syntax.c')
-rw-r--r--src/syntax.c28
1 files changed, 20 insertions, 8 deletions
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(&regmatch, lnum, (colnr_T)0,
+ r = syn_regexec(&regmatch, 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(&regmatch,
+ r = syn_regexec(&regmatch,
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(&regmatch, startpos->lnum, lc_col,
- IF_SYN_TIME(&spp->sp_time)))
+ r = syn_regexec(&regmatch, 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(&regmatch, startpos->lnum, lc_col,
- IF_SYN_TIME(&spp_skip->sp_time))
- && regmatch.startpos[0].col
+ r = syn_regexec(&regmatch, 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 */