To: vim_dev@googlegroups.com Subject: Patch 7.4.1576 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ 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) Files: src/ex_cmds.c *** ../vim-7.4.1575/src/ex_cmds.c 2016-03-15 15:09:25.225513841 +0100 --- src/ex_cmds.c 2016-03-15 18:19:54.223369984 +0100 *************** *** 2065,2090 **** viminfo_errcnt = 0; do_viminfo(fp_in, fp_out, forceit ? 0 : (VIF_WANT_INFO | VIF_WANT_MARKS)); ! fclose(fp_out); /* errors are ignored !? */ 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) { ! ++viminfo_errcnt; ! EMSG2(_("E886: Can't rename viminfo file to %s!"), fname); } 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: --- 2065,2094 ---- viminfo_errcnt = 0; do_viminfo(fp_in, fp_out, forceit ? 0 : (VIF_WANT_INFO | VIF_WANT_MARKS)); ! 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) { ! 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); } end: *** ../vim-7.4.1575/src/version.c 2016-03-15 18:09:53.317599021 +0100 --- src/version.c 2016-03-15 18:22:55.309492951 +0100 *************** *** 745,746 **** --- 745,748 ---- { /* Add new patch number below this line */ + /**/ + 1576, /**/ -- hundred-and-one symptoms of being an internet addict: 51. You put a pillow case over your laptop so your lover doesn't see it while you are pretending to catch your breath. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///