summaryrefslogtreecommitdiff
path: root/src/os_win32.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2012-10-21 02:37:10 +0200
committerBram Moolenaar <Bram@vim.org>2012-10-21 02:37:10 +0200
commitfaca84059a6ef728e1326becc2f82345a59b50c7 (patch)
tree166d74d0918c6a2ced6f82ffedfdbff5fea63825 /src/os_win32.c
parentcfb807026f678e2e99c98baa2b2b7e74b82b0fc7 (diff)
downloadvim-faca84059a6ef728e1326becc2f82345a59b50c7.zip
updated for version 7.3.701
Problem: MS-Windows: Crash with stack overflow when setting 'encoding'. Solution: Handle that loading the iconv library may be called recursively. (Jiri Sedlak)
Diffstat (limited to 'src/os_win32.c')
-rw-r--r--src/os_win32.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/os_win32.c b/src/os_win32.c
index 8151e6054..006a36144 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;
}