comparison src/ex_cmds.c @ 8573:c76cb97073bd v7.4.1576

commit https://github.com/vim/vim/commit/927030af23982a70580178e32806cd3638ce6e5b Author: Bram Moolenaar <Bram@vim.org> Date: Tue Mar 15 18:23:55 2016 +0100 patch 7.4.1576 Problem: Write error of viminfo file is not handled properly. (Christian Neukirchen) Solution: Check the return value of fclose(). (closes https://github.com/vim/vim/issues/682)
author Christian Brabandt <cb@256bit.org>
date Tue, 15 Mar 2016 18:30:08 +0100
parents f3c636c673f7
children 24b43dd167eb
comparison
equal deleted inserted replaced
8572:3a9940e5a43c 8573:c76cb97073bd
2063 } 2063 }
2064 2064
2065 viminfo_errcnt = 0; 2065 viminfo_errcnt = 0;
2066 do_viminfo(fp_in, fp_out, forceit ? 0 : (VIF_WANT_INFO | VIF_WANT_MARKS)); 2066 do_viminfo(fp_in, fp_out, forceit ? 0 : (VIF_WANT_INFO | VIF_WANT_MARKS));
2067 2067
2068 fclose(fp_out); /* errors are ignored !? */ 2068 if (fclose(fp_out) == EOF)
2069 ++viminfo_errcnt;
2070
2069 if (fp_in != NULL) 2071 if (fp_in != NULL)
2070 { 2072 {
2071 fclose(fp_in); 2073 fclose(fp_in);
2072 2074
2073 /* In case of an error keep the original viminfo file. Otherwise 2075 /* In case of an error keep the original viminfo file. Otherwise
2074 * rename the newly written file. Give an error if that fails. */ 2076 * 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)
2076 { 2078 {
2077 ++viminfo_errcnt; 2079 if (vim_rename(tempname, fname) == -1)
2078 EMSG2(_("E886: Can't rename viminfo file to %s!"), fname); 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
2079 } 2089 }
2080 if (viminfo_errcnt > 0) 2090 if (viminfo_errcnt > 0)
2081 mch_remove(tempname); 2091 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
2088 } 2092 }
2089 2093
2090 end: 2094 end:
2091 vim_free(fname); 2095 vim_free(fname);
2092 vim_free(tempname); 2096 vim_free(tempname);