0
0
mirror of https://github.com/vim/vim.git synced 2025-10-07 05:54:16 -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:
Bram Moolenaar
2014-11-19 16:38:07 +01:00
parent df46f6f07f
commit dffa5b8ecf
10 changed files with 98 additions and 64 deletions

View File

@@ -1154,11 +1154,14 @@ spell_check(wp, ptr, attrp, capcol, docount)
if (capcol != NULL && wp->w_s->b_cap_prog != NULL)
{
regmatch_T regmatch;
int r;
/* Check for end of sentence. */
regmatch.regprog = wp->w_s->b_cap_prog;
regmatch.rm_ic = FALSE;
if (vim_regexec(&regmatch, ptr, 0))
r = vim_regexec(&regmatch, ptr, 0);
wp->w_s->b_cap_prog = regmatch.regprog;
if (r)
*capcol = (int)(regmatch.endp[0] - ptr);
}
@@ -1786,7 +1789,6 @@ can_compound(slang, word, flags)
char_u *word;
char_u *flags;
{
regmatch_T regmatch;
#ifdef FEAT_MBYTE
char_u uflags[MAXWLEN * 2];
int i;
@@ -1808,9 +1810,7 @@ can_compound(slang, word, flags)
else
#endif
p = flags;
regmatch.regprog = slang->sl_compprog;
regmatch.rm_ic = FALSE;
if (!vim_regexec(&regmatch, p, 0))
if (!vim_regexec_prog(&slang->sl_compprog, FALSE, p, 0))
return FALSE;
/* Count the number of syllables. This may be slow, do it last. If there
@@ -1930,8 +1930,7 @@ valid_word_prefix(totprefcnt, arridx, flags, word, slang, cond_req)
{
int prefcnt;
int pidx;
regprog_T *rp;
regmatch_T regmatch;
regprog_T **rp;
int prefid;
prefid = (unsigned)flags >> 24;
@@ -1950,12 +1949,10 @@ valid_word_prefix(totprefcnt, arridx, flags, word, slang, cond_req)
/* Check the condition, if there is one. The condition index is
* stored in the two bytes above the prefix ID byte. */
rp = slang->sl_prefprog[((unsigned)pidx >> 8) & 0xffff];
if (rp != NULL)
rp = &slang->sl_prefprog[((unsigned)pidx >> 8) & 0xffff];
if (*rp != NULL)
{
regmatch.regprog = rp;
regmatch.rm_ic = FALSE;
if (!vim_regexec(&regmatch, word, 0))
if (!vim_regexec_prog(rp, FALSE, word, 0))
continue;
}
else if (cond_req)
@@ -6903,7 +6900,6 @@ store_aff_word(spin, word, afflist, affile, ht, xht, condit, flags,
hashitem_T *hi;
affheader_T *ah;
affentry_T *ae;
regmatch_T regmatch;
char_u newword[MAXWLEN];
int retval = OK;
int i, j;
@@ -6944,15 +6940,14 @@ store_aff_word(spin, word, afflist, affile, ht, xht, condit, flags,
* When a previously added affix had CIRCUMFIX this one
* must have it too, if it had not then this one must not
* have one either. */
regmatch.regprog = ae->ae_prog;
regmatch.rm_ic = FALSE;
if ((xht != NULL || !affile->af_pfxpostpone
|| ae->ae_chop != NULL
|| ae->ae_flags != NULL)
&& (ae->ae_chop == NULL
|| STRLEN(ae->ae_chop) < wordlen)
&& (ae->ae_prog == NULL
|| vim_regexec(&regmatch, word, (colnr_T)0))
|| vim_regexec_prog(&ae->ae_prog, FALSE,
word, (colnr_T)0))
&& (((condit & CONDIT_CFIX) == 0)
== ((condit & CONDIT_AFF) == 0
|| ae->ae_flags == NULL
@@ -10478,6 +10473,7 @@ check_need_cap(lnum, col)
break;
}
}
curwin->w_s->b_cap_prog = regmatch.regprog;
}
vim_free(line_copy);