• R/O
  • SSH

vim: コミット

Mirror of the Vim source from https://github.com/vim/vim


コミットメタ情報

リビジョンc3570bdc93eb1b6e79fa0d2cf29cf27ae07de1d1 (tree)
日時2022-05-15 23:00:03
作者Bram Moolenaar <Bram@vim....>
コミッターBram Moolenaar

ログメッセージ

patch 8.2.4959: using NULL regexp program

Commit: https://github.com/vim/vim/commit/b62dc5e7825bc195efe3041d5b3a9f1528359e1c
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun May 15 14:50:12 2022 +0100

patch 8.2.4959: using NULL regexp program
Problem: Using NULL regexp program.
Solution: Check for regexp program becoming NULL in more places.

変更サマリ

差分

diff -r d86ddacad21d -r c3570bdc93eb src/buffer.c
--- a/src/buffer.c Sun May 15 15:00:03 2022 +0200
+++ b/src/buffer.c Sun May 15 16:00:03 2022 +0200
@@ -2642,13 +2642,15 @@
26422642 if (*p == '^' && !(attempt & 1)) // add/remove '^'
26432643 ++p;
26442644 regmatch.regprog = vim_regcomp(p, magic_isset() ? RE_MAGIC : 0);
2645- if (regmatch.regprog == NULL)
2646- {
2647- vim_free(pat);
2648- return -1;
2649- }
26502645
26512646 FOR_ALL_BUFS_FROM_LAST(buf)
2647+ {
2648+ if (regmatch.regprog == NULL)
2649+ {
2650+ // invalid pattern, possibly after switching engine
2651+ vim_free(pat);
2652+ return -1;
2653+ }
26522654 if (buf->b_p_bl == find_listed
26532655 #ifdef FEAT_DIFF
26542656 && (!diffmode || diff_mode_buf(buf))
@@ -2674,6 +2676,7 @@
26742676 }
26752677 match = buf->b_fnum; // remember first match
26762678 }
2679+ }
26772680
26782681 vim_regfree(regmatch.regprog);
26792682 if (match >= 0) // found one match
@@ -2766,12 +2769,6 @@
27662769 if (attempt > 0 && patc == pat)
27672770 break; // there was no anchor, no need to try again
27682771 regmatch.regprog = vim_regcomp(patc + attempt * 11, RE_MAGIC);
2769- if (regmatch.regprog == NULL)
2770- {
2771- if (patc != pat)
2772- vim_free(patc);
2773- return FAIL;
2774- }
27752772 }
27762773
27772774 // round == 1: Count the matches.
@@ -2792,7 +2789,16 @@
27922789 #endif
27932790
27942791 if (!fuzzy)
2792+ {
2793+ if (regmatch.regprog == NULL)
2794+ {
2795+ // invalid pattern, possibly after recompiling
2796+ if (patc != pat)
2797+ vim_free(patc);
2798+ return FAIL;
2799+ }
27952800 p = buflist_match(&regmatch, buf, p_wic);
2801+ }
27962802 else
27972803 {
27982804 p = NULL;
@@ -2921,6 +2927,7 @@
29212927
29222928 /*
29232929 * Check for a match on the file name for buffer "buf" with regprog "prog".
2930+ * Note that rmp->regprog may become NULL when switching regexp engine.
29242931 */
29252932 static char_u *
29262933 buflist_match(
@@ -2939,7 +2946,8 @@
29392946 }
29402947
29412948 /*
2942- * Try matching the regexp in "prog" with file name "name".
2949+ * Try matching the regexp in "rmp->regprog" with file name "name".
2950+ * Note that rmp->regprog may become NULL when switching regexp engine.
29432951 * Return "name" when there is a match, NULL when not.
29442952 */
29452953 static char_u *
@@ -2951,7 +2959,8 @@
29512959 char_u *match = NULL;
29522960 char_u *p;
29532961
2954- if (name != NULL)
2962+ // extra check for valid arguments
2963+ if (name != NULL && rmp->regprog != NULL)
29552964 {
29562965 // Ignore case when 'fileignorecase' or the argument is set.
29572966 rmp->rm_ic = p_fic || ignore_case;
diff -r d86ddacad21d -r c3570bdc93eb src/testdir/test_buffer.vim
--- a/src/testdir/test_buffer.vim Sun May 15 15:00:03 2022 +0200
+++ b/src/testdir/test_buffer.vim Sun May 15 16:00:03 2022 +0200
@@ -419,6 +419,12 @@
419419 vsplit 00000000000000000000000000
420420 silent! buf [0--]\&\zs*\zs*e
421421 bwipe!
422+
423+ " similar case with different code path
424+ split 0
425+ edit ÿ
426+ silent! buf [0--]\&\zs*\zs*0
427+ bwipe!
422428 endfunc
423429
424430 " Test for the 'maxmem' and 'maxmemtot' options
diff -r d86ddacad21d -r c3570bdc93eb src/version.c
--- a/src/version.c Sun May 15 15:00:03 2022 +0200
+++ b/src/version.c Sun May 15 16:00:03 2022 +0200
@@ -747,6 +747,8 @@
747747 static int included_patches[] =
748748 { /* Add new patch number below this line */
749749 /**/
750+ 4959,
751+/**/
750752 4958,
751753 /**/
752754 4957,
旧リポジトリブラウザで表示