Karsten Hopp ffc579
To: vim_dev@googlegroups.com
Karsten Hopp ffc579
Subject: Patch 7.3.349
Karsten Hopp ffc579
Fcc: outbox
Karsten Hopp ffc579
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp ffc579
Mime-Version: 1.0
Karsten Hopp ffc579
Content-Type: text/plain; charset=UTF-8
Karsten Hopp ffc579
Content-Transfer-Encoding: 8bit
Karsten Hopp ffc579
------------
Karsten Hopp ffc579
Karsten Hopp ffc579
Patch 7.3.349
Karsten Hopp ffc579
Problem:    When running out of memory during startup trying to open a
Karsten Hopp ffc579
	    swapfile will loop forever.
Karsten Hopp ffc579
Solution:   Let findswapname() set dirp to NULL if out of memory.
Karsten Hopp ffc579
Files:	    src/memline.c
Karsten Hopp ffc579
Karsten Hopp ffc579
Karsten Hopp ffc579
*** ../vim-7.3.348/src/memline.c	2011-06-13 01:07:22.000000000 +0200
Karsten Hopp ffc579
--- src/memline.c	2011-10-26 11:26:06.000000000 +0200
Karsten Hopp ffc579
***************
Karsten Hopp ffc579
*** 621,626 ****
Karsten Hopp ffc579
--- 621,628 ----
Karsten Hopp ffc579
  	    break;
Karsten Hopp ffc579
  	fname = findswapname(buf, &dirp, mfp->mf_fname);
Karsten Hopp ffc579
  						    /* alloc's fname */
Karsten Hopp ffc579
+ 	if (dirp == NULL)	    /* out of memory */
Karsten Hopp ffc579
+ 	    break;
Karsten Hopp ffc579
  	if (fname == NULL)	    /* no file name found for this dir */
Karsten Hopp ffc579
  	    continue;
Karsten Hopp ffc579
  
Karsten Hopp ffc579
***************
Karsten Hopp ffc579
*** 744,749 ****
Karsten Hopp ffc579
--- 746,753 ----
Karsten Hopp ffc579
  	 * and creating it, another Vim creates the file.  In that case the
Karsten Hopp ffc579
  	 * creation will fail and we will use another directory. */
Karsten Hopp ffc579
  	fname = findswapname(buf, &dirp, NULL); /* allocates fname */
Karsten Hopp ffc579
+ 	if (dirp == NULL)
Karsten Hopp ffc579
+ 	    break;  /* out of memory */
Karsten Hopp ffc579
  	if (fname == NULL)
Karsten Hopp ffc579
  	    continue;
Karsten Hopp ffc579
  	if (mf_open_file(mfp, fname) == OK)	/* consumes fname! */
Karsten Hopp ffc579
***************
Karsten Hopp ffc579
*** 4114,4119 ****
Karsten Hopp ffc579
--- 4118,4124 ----
Karsten Hopp ffc579
   *
Karsten Hopp ffc579
   * Several names are tried to find one that does not exist
Karsten Hopp ffc579
   * Returns the name in allocated memory or NULL.
Karsten Hopp ffc579
+  * When out of memory "dirp" is set to NULL.
Karsten Hopp ffc579
   *
Karsten Hopp ffc579
   * Note: If BASENAMELEN is not correct, you will get error messages for
Karsten Hopp ffc579
   *	 not being able to open the swap or undo file
Karsten Hopp ffc579
***************
Karsten Hopp ffc579
*** 4157,4163 ****
Karsten Hopp ffc579
       * First allocate some memory to put the directory name in.
Karsten Hopp ffc579
       */
Karsten Hopp ffc579
      dir_name = alloc((unsigned)STRLEN(*dirp) + 1);
Karsten Hopp ffc579
!     if (dir_name != NULL)
Karsten Hopp ffc579
  	(void)copy_option_part(dirp, dir_name, 31000, ",");
Karsten Hopp ffc579
  
Karsten Hopp ffc579
      /*
Karsten Hopp ffc579
--- 4162,4170 ----
Karsten Hopp ffc579
       * First allocate some memory to put the directory name in.
Karsten Hopp ffc579
       */
Karsten Hopp ffc579
      dir_name = alloc((unsigned)STRLEN(*dirp) + 1);
Karsten Hopp ffc579
!     if (dir_name == NULL)
Karsten Hopp ffc579
! 	*dirp = NULL;
Karsten Hopp ffc579
!     else
Karsten Hopp ffc579
  	(void)copy_option_part(dirp, dir_name, 31000, ",");
Karsten Hopp ffc579
  
Karsten Hopp ffc579
      /*
Karsten Hopp ffc579
*** ../vim-7.3.348/src/version.c	2011-10-26 11:40:56.000000000 +0200
Karsten Hopp ffc579
--- src/version.c	2011-10-26 11:43:05.000000000 +0200
Karsten Hopp ffc579
***************
Karsten Hopp ffc579
*** 716,717 ****
Karsten Hopp ffc579
--- 716,719 ----
Karsten Hopp ffc579
  {   /* Add new patch number below this line */
Karsten Hopp ffc579
+ /**/
Karsten Hopp ffc579
+     349,
Karsten Hopp ffc579
  /**/
Karsten Hopp ffc579
Karsten Hopp ffc579
-- 
Karsten Hopp ffc579
I AM THANKFUL...
Karsten Hopp ffc579
...for all the complaining I hear about the government
Karsten Hopp ffc579
because it means we have freedom of speech.
Karsten Hopp ffc579
Karsten Hopp ffc579
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp ffc579
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp ffc579
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp ffc579
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///