0
0
mirror of https://github.com/vim/vim.git synced 2025-09-30 04:44:14 -04:00

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)
This commit is contained in:
Bram Moolenaar
2016-03-15 18:23:55 +01:00
parent 89e375a88f
commit 927030af23
2 changed files with 16 additions and 10 deletions

View File

@@ -2065,26 +2065,30 @@ write_viminfo(char_u *file, int forceit)
viminfo_errcnt = 0; viminfo_errcnt = 0;
do_viminfo(fp_in, fp_out, forceit ? 0 : (VIF_WANT_INFO | VIF_WANT_MARKS)); 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) if (fp_in != NULL)
{ {
fclose(fp_in); fclose(fp_in);
/* In case of an error keep the original viminfo file. Otherwise /* In case of an error keep the original viminfo file. Otherwise
* rename the newly written file. Give an error if that fails. */ * 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; if (vim_rename(tempname, fname) == -1)
EMSG2(_("E886: Can't rename viminfo file to %s!"), fname); {
++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) if (viminfo_errcnt > 0)
mch_remove(tempname); mch_remove(tempname);
#ifdef WIN3264
/* If the viminfo file was hidden then also hide the new file. */
if (hidden)
mch_hide(fname);
#endif
} }
end: end:

View File

@@ -743,6 +743,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1576,
/**/ /**/
1575, 1575,
/**/ /**/