Karsten Hopp f615fd
To: vim_dev@googlegroups.com
Karsten Hopp f615fd
Subject: Patch 7.3.701
Karsten Hopp f615fd
Fcc: outbox
Karsten Hopp f615fd
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp f615fd
Mime-Version: 1.0
Karsten Hopp f615fd
Content-Type: text/plain; charset=UTF-8
Karsten Hopp f615fd
Content-Transfer-Encoding: 8bit
Karsten Hopp f615fd
------------
Karsten Hopp f615fd
Karsten Hopp f615fd
Patch 7.3.701
Karsten Hopp f615fd
Problem:    MS-Windows: Crash with stack overflow when setting 'encoding'.
Karsten Hopp f615fd
Solution:   Handle that loading the iconv library may be called recursively.
Karsten Hopp f615fd
            (Jiri Sedlak)
Karsten Hopp f615fd
Files:      src/os_win32.c
Karsten Hopp f615fd
Karsten Hopp f615fd
Karsten Hopp f615fd
*** ../vim-7.3.700/src/os_win32.c	2012-08-02 12:31:40.000000000 +0200
Karsten Hopp f615fd
--- src/os_win32.c	2012-10-21 02:35:21.000000000 +0200
Karsten Hopp f615fd
***************
Karsten Hopp f615fd
*** 288,305 ****
Karsten Hopp f615fd
  vimLoadLib(char *name)
Karsten Hopp f615fd
  {
Karsten Hopp f615fd
      HINSTANCE dll = NULL;
Karsten Hopp f615fd
!     char old_dir[MAXPATHL];
Karsten Hopp f615fd
  
Karsten Hopp f615fd
      if (exe_path == NULL)
Karsten Hopp f615fd
  	get_exe_name();
Karsten Hopp f615fd
!     if (exe_path != NULL && mch_dirname(old_dir, MAXPATHL) == OK)
Karsten Hopp f615fd
      {
Karsten Hopp f615fd
  	/* Change directory to where the executable is, both to make sure we
Karsten Hopp f615fd
  	 * find a .dll there and to avoid looking for a .dll in the current
Karsten Hopp f615fd
  	 * directory. */
Karsten Hopp f615fd
! 	mch_chdir(exe_path);
Karsten Hopp f615fd
  	dll = LoadLibrary(name);
Karsten Hopp f615fd
- 	mch_chdir(old_dir);
Karsten Hopp f615fd
      }
Karsten Hopp f615fd
      return dll;
Karsten Hopp f615fd
  }
Karsten Hopp f615fd
--- 288,313 ----
Karsten Hopp f615fd
  vimLoadLib(char *name)
Karsten Hopp f615fd
  {
Karsten Hopp f615fd
      HINSTANCE dll = NULL;
Karsten Hopp f615fd
!     TCHAR old_dir[MAXPATHL];
Karsten Hopp f615fd
  
Karsten Hopp f615fd
+     /* NOTE: Do not use mch_dirname() and mch_chdir() here, they may call
Karsten Hopp f615fd
+      * vimLoadLib() recursively, which causes a stack overflow. */
Karsten Hopp f615fd
      if (exe_path == NULL)
Karsten Hopp f615fd
  	get_exe_name();
Karsten Hopp f615fd
!     if (exe_path != NULL && GetCurrentDirectory(MAXPATHL, old_dir) != 0)
Karsten Hopp f615fd
      {
Karsten Hopp f615fd
  	/* Change directory to where the executable is, both to make sure we
Karsten Hopp f615fd
  	 * find a .dll there and to avoid looking for a .dll in the current
Karsten Hopp f615fd
  	 * directory. */
Karsten Hopp f615fd
! 	SetCurrentDirectory(exe_path);
Karsten Hopp f615fd
! 	dll = LoadLibrary(name);
Karsten Hopp f615fd
! 	SetCurrentDirectory(old_dir);
Karsten Hopp f615fd
!     }
Karsten Hopp f615fd
!     else
Karsten Hopp f615fd
!     {
Karsten Hopp f615fd
! 	/* We are not able to change directory to where the executable is, try
Karsten Hopp f615fd
! 	 * to load library anyway. */
Karsten Hopp f615fd
  	dll = LoadLibrary(name);
Karsten Hopp f615fd
      }
Karsten Hopp f615fd
      return dll;
Karsten Hopp f615fd
  }
Karsten Hopp f615fd
*** ../vim-7.3.700/src/version.c	2012-10-21 02:17:28.000000000 +0200
Karsten Hopp f615fd
--- src/version.c	2012-10-21 02:35:48.000000000 +0200
Karsten Hopp f615fd
***************
Karsten Hopp f615fd
*** 721,722 ****
Karsten Hopp f615fd
--- 721,724 ----
Karsten Hopp f615fd
  {   /* Add new patch number below this line */
Karsten Hopp f615fd
+ /**/
Karsten Hopp f615fd
+     701,
Karsten Hopp f615fd
  /**/
Karsten Hopp f615fd
Karsten Hopp f615fd
-- 
Karsten Hopp f615fd
BEDEVERE: And that, my lord, is how we know the Earth to be banana-shaped.
Karsten Hopp f615fd
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
Karsten Hopp f615fd
Karsten Hopp f615fd
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp f615fd
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp f615fd
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp f615fd
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///