]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.1434: crash when adding package already in 'runtimepath' v9.0.1434
authorzeertzjq <zeertzjq@outlook.com>
Sat, 1 Apr 2023 12:52:03 +0000 (13:52 +0100)
committerBram Moolenaar <Bram@vim.org>
Sat, 1 Apr 2023 12:52:03 +0000 (13:52 +0100)
Problem:    Crash when adding package already in 'runtimepath'.
Solution:   Change order for using 'runtimepath' entries. (closes #12215)

src/scriptfile.c
src/testdir/test_packadd.vim
src/version.c

index dd4a35236ea10b9e75cfa871a2fc540a5734bd71..0afe20110bfc3cacee4f689e3c0ac96e2327a539 100644 (file)
@@ -718,18 +718,6 @@ add_pack_dir_to_rtp(char_u *fname)
        char_u *cur_entry = entry;
 
        copy_option_part(&entry, buf, MAXPATHL, ",");
-       if (insp == NULL)
-       {
-           add_pathsep(buf);
-           rtp_ffname = fix_fname(buf);
-           if (rtp_ffname == NULL)
-               goto theend;
-           match = vim_fnamencmp(rtp_ffname, ffname, fname_len) == 0;
-           vim_free(rtp_ffname);
-           if (match)
-               // Insert "ffname" after this entry (and comma).
-               insp = entry;
-       }
 
        if ((p = (char_u *)strstr((char *)buf, "after")) != NULL
                && p > buf
@@ -743,6 +731,19 @@ add_pack_dir_to_rtp(char_u *fname)
            after_insp = cur_entry;
            break;
        }
+
+       if (insp == NULL)
+       {
+           add_pathsep(buf);
+           rtp_ffname = fix_fname(buf);
+           if (rtp_ffname == NULL)
+               goto theend;
+           match = vim_fnamencmp(rtp_ffname, ffname, fname_len) == 0;
+           vim_free(rtp_ffname);
+           if (match)
+               // Insert "ffname" after this entry (and comma).
+               insp = entry;
+       }
     }
 
     if (insp == NULL)
index 89b7817682951e133c0f980df4774c5d2abf27c2..b44494acf98937c2a2e20fd4252214c678c404ea 100644 (file)
@@ -21,6 +21,13 @@ func Test_packadd()
   call mkdir(s:plugdir . '/plugin/also', 'p')
   call mkdir(s:plugdir . '/ftdetect', 'p')
   call mkdir(s:plugdir . '/after', 'p')
+
+  " This used to crash Vim
+  let &rtp = 'nosuchdir,' . s:plugdir . '/after'
+  packadd mytest
+  " plugdir should be inserted before plugdir/after
+  call assert_match('^nosuchdir,' . s:plugdir . ',', &rtp)
+
   set rtp&
   let rtp = &rtp
   filetype on
index 76f5f09e7a993904908d37d8124d432c314acc24..f87bc34e791b57309522fdef06dfd2d03020e087 100644 (file)
@@ -695,6 +695,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1434,
 /**/
     1433,
 /**/