]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.2088: Redundant NULL checks in find_pattern_in_path() v9.1.2088
authorzeertzjq <zeertzjq@outlook.com>
Fri, 16 Jan 2026 18:31:33 +0000 (18:31 +0000)
committerChristian Brabandt <cb@256bit.org>
Fri, 16 Jan 2026 18:31:33 +0000 (18:31 +0000)
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 <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/search.c
src/testdir/test_diffmode.vim
src/version.c

index 6400ceb3dcf469d52650dc6461ca56b3e37bc02d..5d50b1fc5b2ac4d1fd587c58f0524559ab8778ad 100644 (file)
@@ -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];
index 7e93ea36367d4128c5bee4db4fb8e7bd049c9e9f..e4ae578201df0448f5038f5565be5bdd5e470230 100644 (file)
@@ -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
 
index 517bffab127ac91331aba7ddb267db667b42eefb..00c2988f990b8a04212abf71f66b05eacca0d2c5 100644 (file)
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2088,
 /**/
     2087,
 /**/