mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
vim-patch:9.0.1434: crash when adding package already in 'runtimepath' (#22849)
Problem: Crash when adding package already in 'runtimepath'.
Solution: Change order for using 'runtimepath' entries. (closes vim/vim#12215)
39c9ec16ea
This commit is contained in:
@@ -914,19 +914,6 @@ static int add_pack_dir_to_rtp(char *fname, bool is_pack)
|
||||
const char *cur_entry = entry;
|
||||
|
||||
copy_option_part((char **)&entry, buf, MAXPATHL, ",");
|
||||
if (insp == NULL) {
|
||||
add_pathsep(buf);
|
||||
char *const rtp_ffname = fix_fname(buf);
|
||||
if (rtp_ffname == NULL) {
|
||||
goto theend;
|
||||
}
|
||||
bool match = path_fnamencmp(rtp_ffname, ffname, fname_len) == 0;
|
||||
xfree(rtp_ffname);
|
||||
if (match) {
|
||||
// Insert "ffname" after this entry (and comma).
|
||||
insp = entry;
|
||||
}
|
||||
}
|
||||
|
||||
if ((p = strstr(buf, "after")) != NULL
|
||||
&& p > buf
|
||||
@@ -940,6 +927,20 @@ static int add_pack_dir_to_rtp(char *fname, bool is_pack)
|
||||
after_insp = cur_entry;
|
||||
break;
|
||||
}
|
||||
|
||||
if (insp == NULL) {
|
||||
add_pathsep(buf);
|
||||
char *const rtp_ffname = fix_fname(buf);
|
||||
if (rtp_ffname == NULL) {
|
||||
goto theend;
|
||||
}
|
||||
bool match = path_fnamencmp(rtp_ffname, ffname, fname_len) == 0;
|
||||
xfree(rtp_ffname);
|
||||
if (match) {
|
||||
// Insert "ffname" after this entry (and comma).
|
||||
insp = entry;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (insp == NULL) {
|
||||
|
@@ -20,6 +20,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
|
||||
|
Reference in New Issue
Block a user