diff options
author | Bram Moolenaar <Bram@vim.org> | 2018-12-29 22:28:46 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2018-12-29 22:28:46 +0100 |
commit | a8bfa1727a370d659dc0ccc3f0fd1763b10b5457 (patch) | |
tree | 17834c1ce84410330af2cae7feecfb589fd5880a | |
parent | 1ea88a3e12e5f6afc5353cd0d6e6d4f4a89ced94 (diff) | |
download | vim-git-a8bfa1727a370d659dc0ccc3f0fd1763b10b5457.tar.gz |
patch 8.1.0661: clipboard regexp might be used recursivelyv8.1.0661
Problem: Clipboard regexp might be used recursively.
Solution: Check for recursive use and bail out.
-rw-r--r-- | src/os_unix.c | 8 | ||||
-rw-r--r-- | src/proto/regexp.pro | 1 | ||||
-rw-r--r-- | src/regexp.c | 9 | ||||
-rw-r--r-- | src/version.c | 2 |
4 files changed, 19 insertions, 1 deletions
diff --git a/src/os_unix.c b/src/os_unix.c index eaf07f101..ec12f3ea7 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -1688,9 +1688,15 @@ x_connect_to_server(void) if (x_no_connect) return FALSE; - /* Check for a match with "exclude:" from 'clipboard'. */ + // Check for a match with "exclude:" from 'clipboard'. if (clip_exclude_prog != NULL) { + // Just in case we get called recursively, return FALSE. This could + // happen if vpeekc() is used while executing the prog and it causes a + // related callback to be invoked. + if (regprog_in_use(clip_exclude_prog)) + return FALSE; + if (vim_regexec_prog(&clip_exclude_prog, FALSE, T_NAME, (colnr_T)0)) return FALSE; } diff --git a/src/proto/regexp.pro b/src/proto/regexp.pro index d22a83b0e..a33fdd989 100644 --- a/src/proto/regexp.pro +++ b/src/proto/regexp.pro @@ -13,6 +13,7 @@ char_u *reg_submatch(int no); list_T *reg_submatch_list(int no); regprog_T *vim_regcomp(char_u *expr_arg, int re_flags); void vim_regfree(regprog_T *prog); +int regprog_in_use(regprog_T *prog); int vim_regexec_prog(regprog_T **prog, int ignore_case, char_u *line, colnr_T col); int vim_regexec(regmatch_T *rmp, char_u *line, colnr_T col); int vim_regexec_nl(regmatch_T *rmp, char_u *line, colnr_T col); diff --git a/src/regexp.c b/src/regexp.c index 011ee2d75..e055dd362 100644 --- a/src/regexp.c +++ b/src/regexp.c @@ -8210,6 +8210,15 @@ report_re_switch(char_u *pat) #endif /* + * Return whether "prog" is currently being executed. + */ + int +regprog_in_use(regprog_T *prog) +{ + return prog->re_in_use; +} + +/* * Match a regexp against a string. * "rmp->regprog" is a compiled regexp as returned by vim_regcomp(). * Note: "rmp->regprog" may be freed and changed. diff --git a/src/version.c b/src/version.c index c98fc5077..c49e8692d 100644 --- a/src/version.c +++ b/src/version.c @@ -800,6 +800,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 661, +/**/ 660, /**/ 659, |