4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
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.
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
22 char_u *browseFile = NULL;
23 int browse_flag = cmdmod.browse;
34 ! if (curbuf->b_fname != NULL)
36 ! newname = vim_strnsave(curbuf->b_fname,
37 (int)(STRLEN(curbuf->b_fname) + 4));
38 ! if (newname != NULL)
39 ! STRCAT(newname, ".new");
43 ! need_mouse_correct = TRUE;
45 ! /* don't use a new tab page, each tab page has its own diffs */
48 ! if (win_split(0, (diff_flags & DIFF_VERTICAL) ? WSP_VERT : 0) != FAIL)
50 ! /* Pretend it was a ":split fname" command */
51 ! eap->cmdidx = CMD_split;
53 ! do_exedit(eap, old_curwin);
55 ! if (curwin != old_curwin) /* split must have worked */
57 ! /* Set 'diff', 'scrollbind' on and 'wrap' off. */
58 ! diff_win_options(curwin, TRUE);
59 ! diff_win_options(old_curwin, TRUE);
61 ! if (newname != NULL)
63 ! /* do a ":file filename.new" on the patched buffer */
68 ! /* Do filetype detection with the new name. */
69 ! if (au_has_group((char_u *)"filetypedetect"))
70 ! do_cmdline_cmd((char_u *)":doau filetypedetect BufRead");
79 ! /* Only continue if the output file was created. */
80 ! if (mch_stat((char *)tmp_new, &st) < 0 || st.st_size == 0)
81 ! EMSG(_("E816: Cannot read patch output"));
84 ! if (curbuf->b_fname != NULL)
86 ! newname = vim_strnsave(curbuf->b_fname,
87 (int)(STRLEN(curbuf->b_fname) + 4));
88 ! if (newname != NULL)
89 ! STRCAT(newname, ".new");
93 ! need_mouse_correct = TRUE;
95 ! /* don't use a new tab page, each tab page has its own diffs */
98 ! if (win_split(0, (diff_flags & DIFF_VERTICAL) ? WSP_VERT : 0) != FAIL)
100 ! /* Pretend it was a ":split fname" command */
101 ! eap->cmdidx = CMD_split;
102 ! eap->arg = tmp_new;
103 ! do_exedit(eap, old_curwin);
105 ! /* check that split worked and editing tmp_new */
106 ! if (curwin != old_curwin && win_valid(old_curwin))
108 ! /* Set 'diff', 'scrollbind' on and 'wrap' off. */
109 ! diff_win_options(curwin, TRUE);
110 ! diff_win_options(old_curwin, TRUE);
112 ! if (newname != NULL)
114 ! /* do a ":file filename.new" on the patched buffer */
115 ! eap->arg = newname;
119 ! /* Do filetype detection with the new name. */
120 ! if (au_has_group((char_u *)"filetypedetect"))
121 ! do_cmdline_cmd((char_u *)":doau filetypedetect BufRead");
127 *** ../vim-7.2.238/src/version.c 2009-07-22 14:27:33.000000000 +0200
128 --- src/version.c 2009-07-22 16:21:29.000000000 +0200
132 { /* Add new patch number below this line */
138 hundred-and-one symptoms of being an internet addict:
139 97. Your mother tells you to remember something, and you look for
142 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
143 /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
144 \\\ download, build and distribute -- http://www.A-A-P.org ///
145 \\\ help me help AIDS victims -- http://ICCF-Holland.org ///