summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2016-03-15 18:23:55 +0100
committerBram Moolenaar <Bram@vim.org>2016-03-15 18:23:55 +0100
commit927030af23982a70580178e32806cd3638ce6e5b (patch)
tree0c0d0863c46bfdb26096f90031fe14ba9e0b218d
parent89e375a88f3eceb73bbd97e78aca1a1c4647c897 (diff)
downloadvim-927030af23982a70580178e32806cd3638ce6e5b.zip
patch 7.4.1576
Problem: Write error of viminfo file is not handled properly. (Christian Neukirchen) Solution: Check the return value of fclose(). (closes #682)
-rw-r--r--src/ex_cmds.c24
-rw-r--r--src/version.c2
2 files changed, 16 insertions, 10 deletions
diff --git a/src/ex_cmds.c b/src/ex_cmds.c
index ae88cc69e..8a763c9a9 100644
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -2065,26 +2065,30 @@ write_viminfo(char_u *file, int forceit)
viminfo_errcnt = 0;
do_viminfo(fp_in, fp_out, forceit ? 0 : (VIF_WANT_INFO | VIF_WANT_MARKS));
- fclose(fp_out); /* errors are ignored !? */
+ if (fclose(fp_out) == EOF)
+ ++viminfo_errcnt;
+
if (fp_in != NULL)
{
fclose(fp_in);
/* In case of an error keep the original viminfo file. Otherwise
* rename the newly written file. Give an error if that fails. */
- if (viminfo_errcnt == 0 && vim_rename(tempname, fname) == -1)
+ if (viminfo_errcnt == 0)
{
- ++viminfo_errcnt;
- EMSG2(_("E886: Can't rename viminfo file to %s!"), fname);
+ if (vim_rename(tempname, fname) == -1)
+ {
+ ++viminfo_errcnt;
+ EMSG2(_("E886: Can't rename viminfo file to %s!"), fname);
+ }
+# ifdef WIN3264
+ /* If the viminfo file was hidden then also hide the new file. */
+ else if (hidden)
+ mch_hide(fname);
+# endif
}
if (viminfo_errcnt > 0)
mch_remove(tempname);
-
-#ifdef WIN3264
- /* If the viminfo file was hidden then also hide the new file. */
- if (hidden)
- mch_hide(fname);
-#endif
}
end:
diff --git a/src/version.c b/src/version.c
index 4ac46b05d..5cc53c8a7 100644
--- a/src/version.c
+++ b/src/version.c
@@ -744,6 +744,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1576,
+/**/
1575,
/**/
1574,