aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/path.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-04-17 14:38:53 +0800
committerGitHub <noreply@github.com>2023-04-17 14:38:53 +0800
commit9722b3b9f983a3401423c41f05dd559f6aa410cd (patch)
treec51b21b35a5b58ff34aeebbbb47101e20b4e788c /src/nvim/path.c
parent85bc9e897039619327b1de85fcdf13ea65c9bb9b (diff)
downloadrneovim-9722b3b9f983a3401423c41f05dd559f6aa410cd.tar.gz
rneovim-9722b3b9f983a3401423c41f05dd559f6aa410cd.tar.bz2
rneovim-9722b3b9f983a3401423c41f05dd559f6aa410cd.zip
vim-patch:9.0.1400: find_file_in_path() is not reentrant (#23146)
Problem: find_file_in_path() is not reentrant. Solution: Instead of global variables pass pointers to the functions. (closes vim/vim#12093) https://github.com/vim/vim/commit/5145c9a829cd43cb9e7962b181bf99226eb3a53f Co-authored-by: Bram Moolenaar <Bram@vim.org>
Diffstat (limited to 'src/nvim/path.c')
-rw-r--r--src/nvim/path.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/nvim/path.c b/src/nvim/path.c
index 8bd3303166..137a8da2bc 100644
--- a/src/nvim/path.c
+++ b/src/nvim/path.c
@@ -1690,8 +1690,11 @@ char *find_file_name_in_path(char *ptr, size_t len, int options, long count, cha
}
if (options & FNAME_EXP) {
- file_name = find_file_in_path(ptr, len, options & ~FNAME_MESS, true,
- rel_fname);
+ char *file_to_find = NULL;
+ char *search_ctx = NULL;
+
+ file_name = find_file_in_path(ptr, len, options & ~FNAME_MESS,
+ true, rel_fname, &file_to_find, &search_ctx);
// If the file could not be found in a normal way, try applying
// 'includeexpr' (unless done already).
@@ -1702,7 +1705,7 @@ char *find_file_name_in_path(char *ptr, size_t len, int options, long count, cha
ptr = tofree;
len = strlen(ptr);
file_name = find_file_in_path(ptr, len, options & ~FNAME_MESS,
- true, rel_fname);
+ true, rel_fname, &file_to_find, &search_ctx);
}
}
if (file_name == NULL && (options & FNAME_MESS)) {
@@ -1716,9 +1719,12 @@ char *find_file_name_in_path(char *ptr, size_t len, int options, long count, cha
// appears several times in the path.
while (file_name != NULL && --count > 0) {
xfree(file_name);
- file_name =
- find_file_in_path(ptr, len, options, false, rel_fname);
+ file_name = find_file_in_path(ptr, len, options, false, rel_fname,
+ &file_to_find, &search_ctx);
}
+
+ xfree(file_to_find);
+ vim_findfile_cleanup(search_ctx);
} else {
file_name = xstrnsave(ptr, len);
}