]> granicus.if.org Git - vim/commitdiff
patch 8.1.0661: clipboard regexp might be used recursively v8.1.0661
authorBram Moolenaar <Bram@vim.org>
Sat, 29 Dec 2018 21:28:46 +0000 (22:28 +0100)
committerBram Moolenaar <Bram@vim.org>
Sat, 29 Dec 2018 21:28:46 +0000 (22:28 +0100)
Problem:    Clipboard regexp might be used recursively.
Solution:   Check for recursive use and bail out.

src/os_unix.c
src/proto/regexp.pro
src/regexp.c
src/version.c

index eaf07f101aac6fdd5c7948230e7a71d3bceffa73..ec12f3ea7ba8fbe78b8869c90f50383cdc519aef 100644 (file)
@@ -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;
     }
index d22a83b0eef71812b904add707f5f32fb64b9dcc..a33fdd98953ec40a1474823f35d6ef33ee82915d 100644 (file)
@@ -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);
index 011ee2d75972f9c792e69f2e1de30897936fd28b..e055dd3623f4d6a7b7bb77f69c19f0a65f464200 100644 (file)
@@ -8209,6 +8209,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().
index c98fc5077b68be4421fcafc9dc3c6964458e5fc3..c49e8692d7c00465aead2f41e3def7883252db0d 100644 (file)
@@ -799,6 +799,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    661,
 /**/
     660,
 /**/