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.2 / 7.2.239 < prev    next >
Encoding:
Internet Message Format  |  2009-07-21  |  4.1 KB

  1. To: vim-dev@vim.org
  2. Subject: Patch 7.2.239
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. Mime-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. ------------
  9.  
  10. Patch 7.2.239
  11. Problem:    Using :diffpatch twice or when patching fails causes memory
  12.         corruption and/or a crash.  (Bryan Venteicher)
  13. Solution:   Detect missing output file.  Avoid using non-existing buffer.
  14. Files:        src/diff.c
  15.  
  16.  
  17. *** ../vim-7.2.238/src/diff.c    2009-05-14 22:19:19.000000000 +0200
  18. --- src/diff.c    2009-07-22 16:06:21.000000000 +0200
  19. ***************
  20. *** 893,898 ****
  21. --- 893,899 ----
  22.       char_u    *browseFile = NULL;
  23.       int        browse_flag = cmdmod.browse;
  24.   #endif
  25. +     struct stat st;
  26.   
  27.   #ifdef FEAT_BROWSE
  28.       if (cmdmod.browse)
  29. ***************
  30. *** 999,1042 ****
  31.       STRCAT(buf, ".rej");
  32.       mch_remove(buf);
  33.   
  34. !     if (curbuf->b_fname != NULL)
  35.       {
  36. !     newname = vim_strnsave(curbuf->b_fname,
  37.                         (int)(STRLEN(curbuf->b_fname) + 4));
  38. !     if (newname != NULL)
  39. !         STRCAT(newname, ".new");
  40. !     }
  41.   
  42.   #ifdef FEAT_GUI
  43. !     need_mouse_correct = TRUE;
  44.   #endif
  45. !     /* don't use a new tab page, each tab page has its own diffs */
  46. !     cmdmod.tab = 0;
  47. !     if (win_split(0, (diff_flags & DIFF_VERTICAL) ? WSP_VERT : 0) != FAIL)
  48. !     {
  49. !     /* Pretend it was a ":split fname" command */
  50. !     eap->cmdidx = CMD_split;
  51. !     eap->arg = tmp_new;
  52. !     do_exedit(eap, old_curwin);
  53.   
  54. !     if (curwin != old_curwin)        /* split must have worked */
  55.       {
  56. !         /* Set 'diff', 'scrollbind' on and 'wrap' off. */
  57. !         diff_win_options(curwin, TRUE);
  58. !         diff_win_options(old_curwin, TRUE);
  59.   
  60. !         if (newname != NULL)
  61.           {
  62. !         /* do a ":file filename.new" on the patched buffer */
  63. !         eap->arg = newname;
  64. !         ex_file(eap);
  65.   
  66.   #ifdef FEAT_AUTOCMD
  67. !         /* Do filetype detection with the new name. */
  68. !         if (au_has_group((char_u *)"filetypedetect"))
  69. !             do_cmdline_cmd((char_u *)":doau filetypedetect BufRead");
  70.   #endif
  71.           }
  72.       }
  73.       }
  74. --- 1000,1050 ----
  75.       STRCAT(buf, ".rej");
  76.       mch_remove(buf);
  77.   
  78. !     /* Only continue if the output file was created. */
  79. !     if (mch_stat((char *)tmp_new, &st) < 0 || st.st_size == 0)
  80. !     EMSG(_("E816: Cannot read patch output"));
  81. !     else
  82.       {
  83. !     if (curbuf->b_fname != NULL)
  84. !     {
  85. !         newname = vim_strnsave(curbuf->b_fname,
  86.                         (int)(STRLEN(curbuf->b_fname) + 4));
  87. !         if (newname != NULL)
  88. !         STRCAT(newname, ".new");
  89. !     }
  90.   
  91.   #ifdef FEAT_GUI
  92. !     need_mouse_correct = TRUE;
  93.   #endif
  94. !     /* don't use a new tab page, each tab page has its own diffs */
  95. !     cmdmod.tab = 0;
  96.   
  97. !     if (win_split(0, (diff_flags & DIFF_VERTICAL) ? WSP_VERT : 0) != FAIL)
  98.       {
  99. !         /* Pretend it was a ":split fname" command */
  100. !         eap->cmdidx = CMD_split;
  101. !         eap->arg = tmp_new;
  102. !         do_exedit(eap, old_curwin);
  103.   
  104. !         /* check that split worked and editing tmp_new */
  105. !         if (curwin != old_curwin && win_valid(old_curwin))
  106.           {
  107. !         /* Set 'diff', 'scrollbind' on and 'wrap' off. */
  108. !         diff_win_options(curwin, TRUE);
  109. !         diff_win_options(old_curwin, TRUE);
  110. !         if (newname != NULL)
  111. !         {
  112. !             /* do a ":file filename.new" on the patched buffer */
  113. !             eap->arg = newname;
  114. !             ex_file(eap);
  115.   
  116.   #ifdef FEAT_AUTOCMD
  117. !             /* Do filetype detection with the new name. */
  118. !             if (au_has_group((char_u *)"filetypedetect"))
  119. !             do_cmdline_cmd((char_u *)":doau filetypedetect BufRead");
  120.   #endif
  121. +         }
  122.           }
  123.       }
  124.       }
  125. *** ../vim-7.2.238/src/version.c    2009-07-22 14:27:33.000000000 +0200
  126. --- src/version.c    2009-07-22 16:21:29.000000000 +0200
  127. ***************
  128. *** 678,679 ****
  129. --- 678,681 ----
  130.   {   /* Add new patch number below this line */
  131. + /**/
  132. +     239,
  133.   /**/
  134.  
  135. -- 
  136. hundred-and-one symptoms of being an internet addict:
  137. 97. Your mother tells you to remember something, and you look for
  138.     a File/Save command.
  139.  
  140.  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
  141. ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
  142. \\\        download, build and distribute -- http://www.A-A-P.org        ///
  143.  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
  144.