diff options
author | Bram Moolenaar <bram@vim.org> | 2012-10-21 02:37:10 +0200 |
---|---|---|
committer | Bram Moolenaar <bram@vim.org> | 2012-10-21 02:37:10 +0200 |
commit | 4379904d7c2aff38ee522855221d673ada3e90da (patch) | |
tree | 787a3a86a650fec88b6f4e6029fd984088e9ef14 | |
parent | 3ab4f3935d4d2709d3ca641bc62f15567256b03f (diff) | |
download | vim-4379904d7c2aff38ee522855221d673ada3e90da.tar.gz |
Problem: MS-Windows: Crash with stack overflow when setting 'encoding'.
Solution: Handle that loading the iconv library may be called recursively.
(Jiri Sedlak)
-rw-r--r-- | src/os_win32.c | 16 | ||||
-rw-r--r-- | src/version.c | 2 |
2 files changed, 14 insertions, 4 deletions
diff --git a/src/os_win32.c b/src/os_win32.c index 8151e605..006a3614 100644 --- a/src/os_win32.c +++ b/src/os_win32.c @@ -288,18 +288,26 @@ unescape_shellxquote(char_u *p, char_u *escaped) vimLoadLib(char *name) { HINSTANCE dll = NULL; - char old_dir[MAXPATHL]; + TCHAR old_dir[MAXPATHL]; + /* NOTE: Do not use mch_dirname() and mch_chdir() here, they may call + * vimLoadLib() recursively, which causes a stack overflow. */ if (exe_path == NULL) get_exe_name(); - if (exe_path != NULL && mch_dirname(old_dir, MAXPATHL) == OK) + if (exe_path != NULL && GetCurrentDirectory(MAXPATHL, old_dir) != 0) { /* Change directory to where the executable is, both to make sure we * find a .dll there and to avoid looking for a .dll in the current * directory. */ - mch_chdir(exe_path); + SetCurrentDirectory(exe_path); + dll = LoadLibrary(name); + SetCurrentDirectory(old_dir); + } + else + { + /* We are not able to change directory to where the executable is, try + * to load library anyway. */ dll = LoadLibrary(name); - mch_chdir(old_dir); } return dll; } diff --git a/src/version.c b/src/version.c index cbe525cc..6afb9d16 100644 --- a/src/version.c +++ b/src/version.c @@ -720,6 +720,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 701, +/**/ 700, /**/ 699, |