Skip to content

Commit 927030a

Browse files
committed
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)
1 parent 89e375a commit 927030a

2 files changed

Lines changed: 16 additions & 10 deletions

File tree

src/ex_cmds.c

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2065,26 +2065,30 @@ write_viminfo(char_u *file, int forceit)
20652065
viminfo_errcnt = 0;
20662066
do_viminfo(fp_in, fp_out, forceit ? 0 : (VIF_WANT_INFO | VIF_WANT_MARKS));
20672067

2068-
fclose(fp_out); /* errors are ignored !? */
2068+
if (fclose(fp_out) == EOF)
2069+
++viminfo_errcnt;
2070+
20692071
if (fp_in != NULL)
20702072
{
20712073
fclose(fp_in);
20722074

20732075
/* In case of an error keep the original viminfo file. Otherwise
20742076
* rename the newly written file. Give an error if that fails. */
2075-
if (viminfo_errcnt == 0 && vim_rename(tempname, fname) == -1)
2077+
if (viminfo_errcnt == 0)
20762078
{
2077-
++viminfo_errcnt;
2078-
EMSG2(_("E886: Can't rename viminfo file to %s!"), fname);
2079+
if (vim_rename(tempname, fname) == -1)
2080+
{
2081+
++viminfo_errcnt;
2082+
EMSG2(_("E886: Can't rename viminfo file to %s!"), fname);
2083+
}
2084+
# ifdef WIN3264
2085+
/* If the viminfo file was hidden then also hide the new file. */
2086+
else if (hidden)
2087+
mch_hide(fname);
2088+
# endif
20792089
}
20802090
if (viminfo_errcnt > 0)
20812091
mch_remove(tempname);
2082-
2083-
#ifdef WIN3264
2084-
/* If the viminfo file was hidden then also hide the new file. */
2085-
if (hidden)
2086-
mch_hide(fname);
2087-
#endif
20882092
}
20892093

20902094
end:

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,8 @@ static char *(features[]) =
743743

744744
static int included_patches[] =
745745
{ /* Add new patch number below this line */
746+
/**/
747+
1576,
746748
/**/
747749
1575,
748750
/**/

0 commit comments

Comments
 (0)