diff options
author | David Bürgin <676c7473@gmail.com> | 2015-04-03 21:08:49 +0200 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2015-04-27 01:41:42 -0400 |
commit | b3519ca73b37879f1b43230d0e1903fdc5c64547 (patch) | |
tree | 37420ff1de0d3b8a2d46bbae9c985b9d9e00e256 /src/nvim/regexp.c | |
parent | 4230f8c332ce56ed2369f1500f7eaceb0bd968f3 (diff) | |
download | rneovim-b3519ca73b37879f1b43230d0e1903fdc5c64547.tar.gz rneovim-b3519ca73b37879f1b43230d0e1903fdc5c64547.tar.bz2 rneovim-b3519ca73b37879f1b43230d0e1903fdc5c64547.zip |
vim-patch:7.4.519
Problem: Crash when using syntax highlighting.
Solution: When regprog is freed and replaced, store the result.
https://github.com/vim/vim/tree/v7-4-519
Helped-by: Scott Prager <splinterofchaos@gmail.com>
Diffstat (limited to 'src/nvim/regexp.c')
-rw-r--r-- | src/nvim/regexp.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c index d9031ab78a..6726b49e77 100644 --- a/src/nvim/regexp.c +++ b/src/nvim/regexp.c @@ -7045,6 +7045,7 @@ static void report_re_switch(char_u *pat) /// Matches a regexp against a string. /// "rmp->regprog" is a compiled regexp as returned by vim_regcomp(). +/// Note: "rmp->regprog" may be freed and changed. /// Uses curbuf for line count and 'iskeyword'. /// When "nl" is true consider a "\n" in "line" to be a line break. /// @@ -7080,12 +7081,24 @@ static int vim_regexec_both(regmatch_T *rmp, char_u *line, colnr_T col, bool nl) return result; } +// Note: "*prog" may be freed and changed. +int vim_regexec_prog(regprog_T **prog, bool ignore_case, char_u *line, + colnr_T col) +{ + regmatch_T regmatch = {.regprog = *prog, .rm_ic = ignore_case}; + int r = vim_regexec_both(®match, line, col, false); + *prog = regmatch.regprog; + return r; +} + +// Note: "rmp->regprog" may be freed and changed. int vim_regexec(regmatch_T *rmp, char_u *line, colnr_T col) { return vim_regexec_both(rmp, line, col, false); } // Like vim_regexec(), but consider a "\n" in "line" to be a line break. +// Note: "rmp->regprog" may be freed and changed. int vim_regexec_nl(regmatch_T *rmp, char_u *line, colnr_T col) { return vim_regexec_both(rmp, line, col, true); @@ -7094,6 +7107,7 @@ int vim_regexec_nl(regmatch_T *rmp, char_u *line, colnr_T col) /* * Match a regexp against multiple lines. * "rmp->regprog" is a compiled regexp as returned by vim_regcomp(). + * Note: "rmp->regprog" may be freed and changed. * Uses curbuf for line count and 'iskeyword'. * * Return zero if there is no match. Return number of lines contained in the |