Karsten Hopp 1562e7
To: vim-dev@vim.org
Karsten Hopp 1562e7
Subject: patch 7.0.231
Karsten Hopp 1562e7
Fcc: outbox
Karsten Hopp 1562e7
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 1562e7
Mime-Version: 1.0
Karsten Hopp 1562e7
Content-Type: text/plain; charset=ISO-8859-1
Karsten Hopp 1562e7
Content-Transfer-Encoding: 8bit
Karsten Hopp 1562e7
------------
Karsten Hopp 1562e7
Karsten Hopp 1562e7
Patch 7.0.231
Karsten Hopp 1562e7
Problem:    When recovering from a swap file the page size is likely to be
Karsten Hopp 1562e7
	    different from the minimum.  The block used for the first page
Karsten Hopp 1562e7
	    then has a buffer of the wrong size, causing a crash when it's
Karsten Hopp 1562e7
	    reused later.  (Zephaniah Hull)
Karsten Hopp 1562e7
Solution:   Reallocate the buffer when the page size changes.  Also check that
Karsten Hopp 1562e7
	    the page size is at least the minimum value.
Karsten Hopp 1562e7
Files:	    src/memline.c
Karsten Hopp 1562e7
Karsten Hopp 1562e7
Karsten Hopp 1562e7
*** ../vim-7.0.230/src/memline.c	Tue Mar  6 20:27:03 2007
Karsten Hopp 1562e7
--- src/memline.c	Thu Apr 19 16:10:39 2007
Karsten Hopp 1562e7
***************
Karsten Hopp 1562e7
*** 1015,1032 ****
Karsten Hopp 1562e7
--- 1015,1053 ----
Karsten Hopp 1562e7
  	msg_end();
Karsten Hopp 1562e7
  	goto theend;
Karsten Hopp 1562e7
      }
Karsten Hopp 1562e7
+ 
Karsten Hopp 1562e7
      /*
Karsten Hopp 1562e7
       * If we guessed the wrong page size, we have to recalculate the
Karsten Hopp 1562e7
       * highest block number in the file.
Karsten Hopp 1562e7
       */
Karsten Hopp 1562e7
      if (mfp->mf_page_size != (unsigned)char_to_long(b0p->b0_page_size))
Karsten Hopp 1562e7
      {
Karsten Hopp 1562e7
+ 	unsigned previous_page_size = mfp->mf_page_size;
Karsten Hopp 1562e7
+ 
Karsten Hopp 1562e7
  	mf_new_page_size(mfp, (unsigned)char_to_long(b0p->b0_page_size));
Karsten Hopp 1562e7
+ 	if (mfp->mf_page_size < previous_page_size)
Karsten Hopp 1562e7
+ 	{
Karsten Hopp 1562e7
+ 	    msg_start();
Karsten Hopp 1562e7
+ 	    msg_outtrans_attr(mfp->mf_fname, attr | MSG_HIST);
Karsten Hopp 1562e7
+ 	    MSG_PUTS_ATTR(_(" has been damaged (page size is smaller than minimum value).\n"),
Karsten Hopp 1562e7
+ 			attr | MSG_HIST);
Karsten Hopp 1562e7
+ 	    msg_end();
Karsten Hopp 1562e7
+ 	    goto theend;
Karsten Hopp 1562e7
+ 	}
Karsten Hopp 1562e7
  	if ((size = lseek(mfp->mf_fd, (off_t)0L, SEEK_END)) <= 0)
Karsten Hopp 1562e7
  	    mfp->mf_blocknr_max = 0;	    /* no file or empty file */
Karsten Hopp 1562e7
  	else
Karsten Hopp 1562e7
  	    mfp->mf_blocknr_max = (blocknr_T)(size / mfp->mf_page_size);
Karsten Hopp 1562e7
  	mfp->mf_infile_count = mfp->mf_blocknr_max;
Karsten Hopp 1562e7
+ 
Karsten Hopp 1562e7
+ 	/* need to reallocate the memory used to store the data */
Karsten Hopp 1562e7
+ 	p = alloc(mfp->mf_page_size);
Karsten Hopp 1562e7
+ 	if (p == NULL)
Karsten Hopp 1562e7
+ 	    goto theend;
Karsten Hopp 1562e7
+ 	mch_memmove(p, hp->bh_data, previous_page_size);
Karsten Hopp 1562e7
+ 	vim_free(hp->bh_data);
Karsten Hopp 1562e7
+ 	hp->bh_data = p;
Karsten Hopp 1562e7
+ 	b0p = (ZERO_BL *)(hp->bh_data);
Karsten Hopp 1562e7
      }
Karsten Hopp 1562e7
  
Karsten Hopp 1562e7
  /*
Karsten Hopp 1562e7
*** ../vim-7.0.230/src/version.c	Thu Apr 26 17:08:16 2007
Karsten Hopp 1562e7
--- src/version.c	Thu Apr 26 17:11:38 2007
Karsten Hopp 1562e7
***************
Karsten Hopp 1562e7
*** 668,669 ****
Karsten Hopp 1562e7
--- 668,671 ----
Karsten Hopp 1562e7
  {   /* Add new patch number below this line */
Karsten Hopp 1562e7
+ /**/
Karsten Hopp 1562e7
+     231,
Karsten Hopp 1562e7
  /**/
Karsten Hopp 1562e7
Karsten Hopp 1562e7
-- 
Karsten Hopp 1562e7
hundred-and-one symptoms of being an internet addict:
Karsten Hopp 1562e7
23. You can't call your mother...she doesn't have a modem.
Karsten Hopp 1562e7
Karsten Hopp 1562e7
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 1562e7
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 1562e7
\\\        download, build and distribute -- http://www.A-A-P.org        ///
Karsten Hopp 1562e7
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///