summaryrefslogtreecommitdiffstats
path: root/gvim/vim-7.2/7.2.239
blob: 26b80ee28463a9dd4852ef89c79ef6980826cc81 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
To: vim-dev@vim.org
Subject: Patch 7.2.239
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 7.2.239
Problem:    Using :diffpatch twice or when patching fails causes memory
	    corruption and/or a crash.  (Bryan Venteicher)
Solution:   Detect missing output file.  Avoid using non-existing buffer.
Files:	    src/diff.c


*** ../vim-7.2.238/src/diff.c	2009-05-14 22:19:19.000000000 +0200
--- src/diff.c	2009-07-22 16:06:21.000000000 +0200
***************
*** 893,898 ****
--- 893,899 ----
      char_u	*browseFile = NULL;
      int		browse_flag = cmdmod.browse;
  #endif
+     struct stat st;
  
  #ifdef FEAT_BROWSE
      if (cmdmod.browse)
***************
*** 999,1042 ****
      STRCAT(buf, ".rej");
      mch_remove(buf);
  
!     if (curbuf->b_fname != NULL)
      {
! 	newname = vim_strnsave(curbuf->b_fname,
  					  (int)(STRLEN(curbuf->b_fname) + 4));
! 	if (newname != NULL)
! 	    STRCAT(newname, ".new");
!     }
  
  #ifdef FEAT_GUI
!     need_mouse_correct = TRUE;
  #endif
!     /* don't use a new tab page, each tab page has its own diffs */
!     cmdmod.tab = 0;
! 
!     if (win_split(0, (diff_flags & DIFF_VERTICAL) ? WSP_VERT : 0) != FAIL)
!     {
! 	/* Pretend it was a ":split fname" command */
! 	eap->cmdidx = CMD_split;
! 	eap->arg = tmp_new;
! 	do_exedit(eap, old_curwin);
  
! 	if (curwin != old_curwin)		/* split must have worked */
  	{
! 	    /* Set 'diff', 'scrollbind' on and 'wrap' off. */
! 	    diff_win_options(curwin, TRUE);
! 	    diff_win_options(old_curwin, TRUE);
  
! 	    if (newname != NULL)
  	    {
! 		/* do a ":file filename.new" on the patched buffer */
! 		eap->arg = newname;
! 		ex_file(eap);
  
  #ifdef FEAT_AUTOCMD
! 		/* Do filetype detection with the new name. */
! 		if (au_has_group((char_u *)"filetypedetect"))
! 		    do_cmdline_cmd((char_u *)":doau filetypedetect BufRead");
  #endif
  	    }
  	}
      }
--- 1000,1050 ----
      STRCAT(buf, ".rej");
      mch_remove(buf);
  
!     /* Only continue if the output file was created. */
!     if (mch_stat((char *)tmp_new, &st) < 0 || st.st_size == 0)
! 	EMSG(_("E816: Cannot read patch output"));
!     else
      {
! 	if (curbuf->b_fname != NULL)
! 	{
! 	    newname = vim_strnsave(curbuf->b_fname,
  					  (int)(STRLEN(curbuf->b_fname) + 4));
! 	    if (newname != NULL)
! 		STRCAT(newname, ".new");
! 	}
  
  #ifdef FEAT_GUI
! 	need_mouse_correct = TRUE;
  #endif
! 	/* don't use a new tab page, each tab page has its own diffs */
! 	cmdmod.tab = 0;
  
! 	if (win_split(0, (diff_flags & DIFF_VERTICAL) ? WSP_VERT : 0) != FAIL)
  	{
! 	    /* Pretend it was a ":split fname" command */
! 	    eap->cmdidx = CMD_split;
! 	    eap->arg = tmp_new;
! 	    do_exedit(eap, old_curwin);
  
! 	    /* check that split worked and editing tmp_new */
! 	    if (curwin != old_curwin && win_valid(old_curwin))
  	    {
! 		/* Set 'diff', 'scrollbind' on and 'wrap' off. */
! 		diff_win_options(curwin, TRUE);
! 		diff_win_options(old_curwin, TRUE);
! 
! 		if (newname != NULL)
! 		{
! 		    /* do a ":file filename.new" on the patched buffer */
! 		    eap->arg = newname;
! 		    ex_file(eap);
  
  #ifdef FEAT_AUTOCMD
! 		    /* Do filetype detection with the new name. */
! 		    if (au_has_group((char_u *)"filetypedetect"))
! 			do_cmdline_cmd((char_u *)":doau filetypedetect BufRead");
  #endif
+ 		}
  	    }
  	}
      }
*** ../vim-7.2.238/src/version.c	2009-07-22 14:27:33.000000000 +0200
--- src/version.c	2009-07-22 16:21:29.000000000 +0200
***************
*** 678,679 ****
--- 678,681 ----
  {   /* Add new patch number below this line */
+ /**/
+     239,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
97. Your mother tells you to remember something, and you look for
    a File/Save command.

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///