diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-04-17 14:38:53 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-17 14:38:53 +0800 |
commit | 9722b3b9f983a3401423c41f05dd559f6aa410cd (patch) | |
tree | c51b21b35a5b58ff34aeebbbb47101e20b4e788c /src/nvim/eval/funcs.c | |
parent | 85bc9e897039619327b1de85fcdf13ea65c9bb9b (diff) | |
download | rneovim-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/eval/funcs.c')
-rw-r--r-- | src/nvim/eval/funcs.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index b064379210..28901d6e55 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -2146,6 +2146,9 @@ static void findfilendir(typval_T *argvars, typval_T *rettv, int find_what) } if (*fname != NUL && !error) { + char *file_to_find = NULL; + char *search_ctx = NULL; + do { if (rettv->v_type == VAR_STRING || rettv->v_type == VAR_LIST) { xfree(fresult); @@ -2156,13 +2159,17 @@ static void findfilendir(typval_T *argvars, typval_T *rettv, int find_what) find_what, curbuf->b_ffname, (find_what == FINDFILE_DIR ? "" - : curbuf->b_p_sua)); + : curbuf->b_p_sua), + &file_to_find, &search_ctx); first = false; if (fresult != NULL && rettv->v_type == VAR_LIST) { tv_list_append_string(rettv->vval.v_list, fresult, -1); } } while ((rettv->v_type == VAR_LIST || --count > 0) && fresult != NULL); + + xfree(file_to_find); + vim_findfile_cleanup(search_ctx); } if (rettv->v_type == VAR_STRING) { |