Commit: patch 9.1.2088: Redundant NULL checks in find_pattern_in_path()

0 views
Skip to first unread message

Christian Brabandt

unread,
1:46 PM (10 hours ago) 1:46 PM
to vim...@googlegroups.com
patch 9.1.2088: Redundant NULL checks in find_pattern_in_path()

Commit: https://github.com/vim/vim/commit/ce394b13e9df1f995525198887f0a2289410a7c5
Author: zeertzjq <zeer...@outlook.com>
Date: Fri Jan 16 18:31:33 2026 +0000

patch 9.1.2088: Redundant NULL checks in find_pattern_in_path()

Problem: Redundant NULL checks in find_pattern_in_path().
Solution: Remove the NULL checks. Also fix typos in test_diffmode.vim
(zeertzjq).

After assigning to inc_opt on line 3461, it's dereferenced immediately,
and not assigned another value afterwards, so checking for NULL after
line 3462 is redundant.

closes: #19185

Signed-off-by: zeertzjq <zeer...@outlook.com>
Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/src/search.c b/src/search.c
index 6400ceb3d..5d50b1fc5 100644
--- a/src/search.c
+++ b/src/search.c
@@ -3496,7 +3496,7 @@ find_pattern_in_path(
char_u *p_fname = (curr_fname == curbuf->b_fname)
? curbuf->b_ffname : curr_fname;

- if (inc_opt != NULL && strstr((char *)inc_opt, "\zs") != NULL)
+ if (strstr((char *)inc_opt, "\zs") != NULL)
// Use text from '\zs' to '\ze' (or end) of 'include'.
new_fname = find_file_name_in_path(incl_regmatch.startp[0],
(int)(incl_regmatch.endp[0] - incl_regmatch.startp[0]),
@@ -3578,8 +3578,7 @@ find_pattern_in_path(
* Isolate the file name.
* Include the surrounding "" or <> if present.
*/
- if (inc_opt != NULL
- && strstr((char *)inc_opt, "\zs") != NULL)
+ if (strstr((char *)inc_opt, "\zs") != NULL)
{
// pattern contains \zs, use the match
p = incl_regmatch.startp[0];
diff --git a/src/testdir/test_diffmode.vim b/src/testdir/test_diffmode.vim
index 7e93ea363..e4ae57820 100644
--- a/src/testdir/test_diffmode.vim
+++ b/src/testdir/test_diffmode.vim
@@ -3566,7 +3566,7 @@ func Test_diff_add_prop_in_autocmd()
call StopVimInTerminal(buf)
endfunc

-" this was causing a use-after-free by callig winframe_remove() rerursively
+" this was causing a use-after-free by calling winframe_remove() recursively
func Test_diffexpr_wipe_buffers()
CheckRunVimInTerminal

diff --git a/src/version.c b/src/version.c
index 517bffab1..00c2988f9 100644
--- a/src/version.c
+++ b/src/version.c
@@ -734,6 +734,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 2088,
/**/
2087,
/**/
Reply all
Reply to author
Forward
0 new messages