home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / patches / 7.0 / 7.0.231 < prev    next >
Encoding:
Internet Message Format  |  2007-04-25  |  2.6 KB

  1. To: vim-dev@vim.org
  2. Subject: patch 7.0.231
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. Mime-Version: 1.0
  6. Content-Type: text/plain; charset=ISO-8859-1
  7. Content-Transfer-Encoding: 8bit
  8. ------------
  9.  
  10. Patch 7.0.231
  11. Problem:    When recovering from a swap file the page size is likely to be
  12.         different from the minimum.  The block used for the first page
  13.         then has a buffer of the wrong size, causing a crash when it's
  14.         reused later.  (Zephaniah Hull)
  15. Solution:   Reallocate the buffer when the page size changes.  Also check that
  16.         the page size is at least the minimum value.
  17. Files:        src/memline.c
  18.  
  19.  
  20. *** ../vim-7.0.230/src/memline.c    Tue Mar  6 20:27:03 2007
  21. --- src/memline.c    Thu Apr 19 16:10:39 2007
  22. ***************
  23. *** 1015,1032 ****
  24. --- 1015,1053 ----
  25.       msg_end();
  26.       goto theend;
  27.       }
  28.       /*
  29.        * If we guessed the wrong page size, we have to recalculate the
  30.        * highest block number in the file.
  31.        */
  32.       if (mfp->mf_page_size != (unsigned)char_to_long(b0p->b0_page_size))
  33.       {
  34. +     unsigned previous_page_size = mfp->mf_page_size;
  35.       mf_new_page_size(mfp, (unsigned)char_to_long(b0p->b0_page_size));
  36. +     if (mfp->mf_page_size < previous_page_size)
  37. +     {
  38. +         msg_start();
  39. +         msg_outtrans_attr(mfp->mf_fname, attr | MSG_HIST);
  40. +         MSG_PUTS_ATTR(_(" has been damaged (page size is smaller than minimum value).\n"),
  41. +             attr | MSG_HIST);
  42. +         msg_end();
  43. +         goto theend;
  44. +     }
  45.       if ((size = lseek(mfp->mf_fd, (off_t)0L, SEEK_END)) <= 0)
  46.           mfp->mf_blocknr_max = 0;        /* no file or empty file */
  47.       else
  48.           mfp->mf_blocknr_max = (blocknr_T)(size / mfp->mf_page_size);
  49.       mfp->mf_infile_count = mfp->mf_blocknr_max;
  50. +     /* need to reallocate the memory used to store the data */
  51. +     p = alloc(mfp->mf_page_size);
  52. +     if (p == NULL)
  53. +         goto theend;
  54. +     mch_memmove(p, hp->bh_data, previous_page_size);
  55. +     vim_free(hp->bh_data);
  56. +     hp->bh_data = p;
  57. +     b0p = (ZERO_BL *)(hp->bh_data);
  58.       }
  59.   
  60.   /*
  61. *** ../vim-7.0.230/src/version.c    Thu Apr 26 17:08:16 2007
  62. --- src/version.c    Thu Apr 26 17:11:38 2007
  63. ***************
  64. *** 668,669 ****
  65. --- 668,671 ----
  66.   {   /* Add new patch number below this line */
  67. + /**/
  68. +     231,
  69.   /**/
  70.  
  71. -- 
  72. hundred-and-one symptoms of being an internet addict:
  73. 23. You can't call your mother...she doesn't have a modem.
  74.  
  75.  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
  76. ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
  77. \\\        download, build and distribute -- http://www.A-A-P.org        ///
  78.  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
  79.