Mercurial > vim
changeset 3889:48af86560945 v7.3.701
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)
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Sun, 21 Oct 2012 02:37:10 +0200 |
parents | d9c47e80cdf9 |
children | 752a37640c62 |
files | src/os_win32.c src/version.c |
diffstat | 2 files changed, 15 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/os_win32.c +++ b/src/os_win32.c @@ -288,18 +288,26 @@ unescape_shellxquote(char_u *p, char_u * 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); - mch_chdir(old_dir); + SetCurrentDirectory(old_dir); + } + else + { + /* We are not able to change directory to where the executable is, try + * to load library anyway. */ + dll = LoadLibrary(name); } return dll; }