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)
diff --git a/src/misc2.c b/src/misc2.c
index e793987..458e62b 100644
--- a/src/misc2.c
+++ b/src/misc2.c
@@ -2473,9 +2473,13 @@
{
char_u *dir_name;
int r;
+ char_u *file_to_find = NULL;
+ char *search_ctx = NULL;
dir_name = find_directory_in_path(new_dir, (int)STRLEN(new_dir),
- FNAME_MESS, curbuf->b_ffname);
+ FNAME_MESS, curbuf->b_ffname, &file_to_find, &search_ctx);
+ vim_free(file_to_find);
+ vim_findfile_cleanup(search_ctx);
if (dir_name == NULL)
return -1;
r = mch_chdir((char *)dir_name);