Hi Bram,

2012/10/21 Sun 9:37:23 UTC+9 Bram Moolenaar:
> Patch 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)
> 
> Files:      src/os_win32.c

As already reported in 
https://groups.google.com/d/msg/vim_dev/1g5QM5Cy-mA/hOva39FXk1MJ,
this patch has a problem.
I sent a patch for the problem and it is already written in the todo.txt:
| Win32: patch for current directory, "loading iof conv". (Ken Takata, 2012 Sep
| 15)

I have updated the patch for 7.3.701.

Best regards,
Ken Takata

-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
# HG changeset patch
# User Ken Takata
# Parent c41599e168790c1cfff6a71ee5851c9ce8458775
Update for 7.3.701 to support Unicode path.
Also fix a comment for definition of _MAX_PATH.

diff --git a/src/os_win32.c b/src/os_win32.c
--- a/src/os_win32.c
+++ b/src/os_win32.c
@@ -302,26 +302,39 @@
 vimLoadLib(char *name)
 {
     HINSTANCE dll = NULL;
-    TCHAR old_dir[MAXPATHL];
+    char 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 && GetCurrentDirectory(MAXPATHL, old_dir) != 0)
+    if (exe_path != NULL)
     {
-	/* 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. */
-	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);
+#ifdef FEAT_MBYTE
+	WCHAR old_dirw[MAXPATHL];
+
+	if (GetCurrentDirectoryW(MAXPATHL, old_dirw) != 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. */
+	    SetCurrentDirectory(exe_path);
+	    dll = LoadLibrary(name);
+	    SetCurrentDirectoryW(old_dirw);
+	    return dll;
+	}
+	/* Retry with non-wide function (for Windows 98). */
+	if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
+#endif
+	    if (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. */
+		SetCurrentDirectory(exe_path);
+		dll = LoadLibrary(name);
+		SetCurrentDirectory(old_dir);
+	    }
     }
     return dll;
 }
diff --git a/src/os_win32.h b/src/os_win32.h
--- a/src/os_win32.h
+++ b/src/os_win32.h
@@ -108,7 +108,7 @@
  */
 #define CMDBUFFSIZE 1024	/* size of the command processing buffer */
 
-/* _MAX_PATH is only 256 (stdlib.h), but we want more for the 'path' option,
+/* _MAX_PATH is only 260 (stdlib.h), but we want more for the 'path' option,
  * thus use a larger number. */
 #define MAXPATHL	1024
 

Raspunde prin e-mail lui