summaryrefslogtreecommitdiffstats
path: root/src/filepath.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2023-03-11 13:55:53 +0000
committerBram Moolenaar <Bram@vim.org>2023-03-11 13:55:53 +0000
commit5145c9a829cd43cb9e7962b181bf99226eb3a53f (patch)
treeb429ed22ce38615b700ef0b868dd6cf5924d7532 /src/filepath.c
parent4df0772a41c361a1c40d220f6fad0b1e1653fc5b (diff)
patch 9.0.1400: find_file_in_path() is not reentrantv9.0.1400
Problem: find_file_in_path() is not reentrant. Solution: Instead of global variables pass pointers to the functions. (closes #12093)
Diffstat (limited to 'src/filepath.c')
-rw-r--r--src/filepath.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/filepath.c b/src/filepath.c
index c448edb049..57e9fb2957 100644
--- a/src/filepath.c
+++ b/src/filepath.c
@@ -982,6 +982,9 @@ findfilendir(
if (*fname != NUL && !error)
{
+ char_u *file_to_find = NULL;
+ char *search_ctx = NULL;
+
do
{
if (rettv->v_type == VAR_STRING || rettv->v_type == VAR_LIST)
@@ -992,13 +995,17 @@ findfilendir(
find_what,
curbuf->b_ffname,
find_what == FINDFILE_DIR
- ? (char_u *)"" : curbuf->b_p_sua);
+ ? (char_u *)"" : curbuf->b_p_sua,
+ &file_to_find, &search_ctx);
first = FALSE;
if (fresult != NULL && rettv->v_type == VAR_LIST)
list_append_string(rettv->vval.v_list, fresult, -1);
} while ((rettv->v_type == VAR_LIST || --count > 0) && fresult != NULL);
+
+ vim_free(file_to_find);
+ vim_findfile_cleanup(search_ctx);
}
if (rettv->v_type == VAR_STRING)