0
0
mirror of https://github.com/vim/vim.git synced 2025-09-24 03:44:06 -04:00

patch 9.0.1400: find_file_in_path() is not reentrant

Problem:    find_file_in_path() is not reentrant.
Solution:   Instead of global variables pass pointers to the functions.
            (closes #12093)
This commit is contained in:
Bram Moolenaar
2023-03-11 13:55:53 +00:00
parent 4df0772a41
commit 5145c9a829
6 changed files with 96 additions and 69 deletions

View File

@@ -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)