lkundrak / rpms / vim

Forked from rpms/vim 4 years ago
Clone
81c2858
To: vim-dev@vim.org
81c2858
Subject: Patch 7.2.239
81c2858
Fcc: outbox
81c2858
From: Bram Moolenaar <Bram@moolenaar.net>
81c2858
Mime-Version: 1.0
81c2858
Content-Type: text/plain; charset=UTF-8
81c2858
Content-Transfer-Encoding: 8bit
81c2858
------------
81c2858
81c2858
Patch 7.2.239
81c2858
Problem:    Using :diffpatch twice or when patching fails causes memory
81c2858
	    corruption and/or a crash.  (Bryan Venteicher)
81c2858
Solution:   Detect missing output file.  Avoid using non-existing buffer.
81c2858
Files:	    src/diff.c
81c2858
81c2858
81c2858
*** ../vim-7.2.238/src/diff.c	2009-05-14 22:19:19.000000000 +0200
81c2858
--- src/diff.c	2009-07-22 16:06:21.000000000 +0200
81c2858
***************
81c2858
*** 893,898 ****
81c2858
--- 893,899 ----
81c2858
      char_u	*browseFile = NULL;
81c2858
      int		browse_flag = cmdmod.browse;
81c2858
  #endif
81c2858
+     struct stat st;
81c2858
  
81c2858
  #ifdef FEAT_BROWSE
81c2858
      if (cmdmod.browse)
81c2858
***************
81c2858
*** 999,1042 ****
81c2858
      STRCAT(buf, ".rej");
81c2858
      mch_remove(buf);
81c2858
  
81c2858
!     if (curbuf->b_fname != NULL)
81c2858
      {
81c2858
! 	newname = vim_strnsave(curbuf->b_fname,
81c2858
  					  (int)(STRLEN(curbuf->b_fname) + 4));
81c2858
! 	if (newname != NULL)
81c2858
! 	    STRCAT(newname, ".new");
81c2858
!     }
81c2858
  
81c2858
  #ifdef FEAT_GUI
81c2858
!     need_mouse_correct = TRUE;
81c2858
  #endif
81c2858
!     /* don't use a new tab page, each tab page has its own diffs */
81c2858
!     cmdmod.tab = 0;
81c2858
! 
81c2858
!     if (win_split(0, (diff_flags & DIFF_VERTICAL) ? WSP_VERT : 0) != FAIL)
81c2858
!     {
81c2858
! 	/* Pretend it was a ":split fname" command */
81c2858
! 	eap->cmdidx = CMD_split;
81c2858
! 	eap->arg = tmp_new;
81c2858
! 	do_exedit(eap, old_curwin);
81c2858
  
81c2858
! 	if (curwin != old_curwin)		/* split must have worked */
81c2858
  	{
81c2858
! 	    /* Set 'diff', 'scrollbind' on and 'wrap' off. */
81c2858
! 	    diff_win_options(curwin, TRUE);
81c2858
! 	    diff_win_options(old_curwin, TRUE);
81c2858
  
81c2858
! 	    if (newname != NULL)
81c2858
  	    {
81c2858
! 		/* do a ":file filename.new" on the patched buffer */
81c2858
! 		eap->arg = newname;
81c2858
! 		ex_file(eap);
81c2858
  
81c2858
  #ifdef FEAT_AUTOCMD
81c2858
! 		/* Do filetype detection with the new name. */
81c2858
! 		if (au_has_group((char_u *)"filetypedetect"))
81c2858
! 		    do_cmdline_cmd((char_u *)":doau filetypedetect BufRead");
81c2858
  #endif
81c2858
  	    }
81c2858
  	}
81c2858
      }
81c2858
--- 1000,1050 ----
81c2858
      STRCAT(buf, ".rej");
81c2858
      mch_remove(buf);
81c2858
  
81c2858
!     /* Only continue if the output file was created. */
81c2858
!     if (mch_stat((char *)tmp_new, &st) < 0 || st.st_size == 0)
81c2858
! 	EMSG(_("E816: Cannot read patch output"));
81c2858
!     else
81c2858
      {
81c2858
! 	if (curbuf->b_fname != NULL)
81c2858
! 	{
81c2858
! 	    newname = vim_strnsave(curbuf->b_fname,
81c2858
  					  (int)(STRLEN(curbuf->b_fname) + 4));
81c2858
! 	    if (newname != NULL)
81c2858
! 		STRCAT(newname, ".new");
81c2858
! 	}
81c2858
  
81c2858
  #ifdef FEAT_GUI
81c2858
! 	need_mouse_correct = TRUE;
81c2858
  #endif
81c2858
! 	/* don't use a new tab page, each tab page has its own diffs */
81c2858
! 	cmdmod.tab = 0;
81c2858
  
81c2858
! 	if (win_split(0, (diff_flags & DIFF_VERTICAL) ? WSP_VERT : 0) != FAIL)
81c2858
  	{
81c2858
! 	    /* Pretend it was a ":split fname" command */
81c2858
! 	    eap->cmdidx = CMD_split;
81c2858
! 	    eap->arg = tmp_new;
81c2858
! 	    do_exedit(eap, old_curwin);
81c2858
  
81c2858
! 	    /* check that split worked and editing tmp_new */
81c2858
! 	    if (curwin != old_curwin && win_valid(old_curwin))
81c2858
  	    {
81c2858
! 		/* Set 'diff', 'scrollbind' on and 'wrap' off. */
81c2858
! 		diff_win_options(curwin, TRUE);
81c2858
! 		diff_win_options(old_curwin, TRUE);
81c2858
! 
81c2858
! 		if (newname != NULL)
81c2858
! 		{
81c2858
! 		    /* do a ":file filename.new" on the patched buffer */
81c2858
! 		    eap->arg = newname;
81c2858
! 		    ex_file(eap);
81c2858
  
81c2858
  #ifdef FEAT_AUTOCMD
81c2858
! 		    /* Do filetype detection with the new name. */
81c2858
! 		    if (au_has_group((char_u *)"filetypedetect"))
81c2858
! 			do_cmdline_cmd((char_u *)":doau filetypedetect BufRead");
81c2858
  #endif
81c2858
+ 		}
81c2858
  	    }
81c2858
  	}
81c2858
      }
81c2858
*** ../vim-7.2.238/src/version.c	2009-07-22 14:27:33.000000000 +0200
81c2858
--- src/version.c	2009-07-22 16:21:29.000000000 +0200
81c2858
***************
81c2858
*** 678,679 ****
81c2858
--- 678,681 ----
81c2858
  {   /* Add new patch number below this line */
81c2858
+ /**/
81c2858
+     239,
81c2858
  /**/
81c2858
81c2858
-- 
81c2858
hundred-and-one symptoms of being an internet addict:
81c2858
97. Your mother tells you to remember something, and you look for
81c2858
    a File/Save command.
81c2858
81c2858
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
81c2858
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
81c2858
\\\        download, build and distribute -- http://www.A-A-P.org        ///
81c2858
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///