To: vim_dev@googlegroups.com Subject: Patch 8.2.3777 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.3777 Problem: Spell file write error not checked. Solution: Check writing the prefix conditions. (Bjorn Linse, closes #9323) Files: src/spellfile.c *** ../vim-8.2.3776/src/spellfile.c 2021-12-09 21:07:07.604331912 +0000 --- src/spellfile.c 2021-12-10 20:36:23.360132986 +0000 *************** *** 303,309 **** for ((np) = (node); (np) != NULL; (np) = (np)->wn_sibling) static int set_spell_finish(spelltab_T *new_st); ! static int write_spell_prefcond(FILE *fd, garray_T *gap); static int read_region_section(FILE *fd, slang_T *slang, int len); static int read_charflags_section(FILE *fd); static int read_prefcond_section(FILE *fd, slang_T *lp); --- 303,309 ---- for ((np) = (node); (np) != NULL; (np) = (np)->wn_sibling) static int set_spell_finish(spelltab_T *new_st); ! static int write_spell_prefcond(FILE *fd, garray_T *gap, size_t *fwv); static int read_region_section(FILE *fd, slang_T *slang, int len); static int read_charflags_section(FILE *fd); static int read_prefcond_section(FILE *fd, slang_T *lp); *************** *** 4977,4986 **** putc(SN_PREFCOND, fd); // putc(SNF_REQUIRED, fd); // ! l = write_spell_prefcond(NULL, &spin->si_prefcond); put_bytes(fd, (long_u)l, 4); // ! write_spell_prefcond(fd, &spin->si_prefcond); } // SN_REP: ... --- 4977,4986 ---- putc(SN_PREFCOND, fd); // putc(SNF_REQUIRED, fd); // ! l = write_spell_prefcond(NULL, &spin->si_prefcond, &fwv); put_bytes(fd, (long_u)l, 4); // ! write_spell_prefcond(fd, &spin->si_prefcond, &fwv); } // SN_REP: ... *************** *** 6567,6582 **** /* * Write the table with prefix conditions to the .spl file. ! * When "fd" is NULL only count the length of what is written. */ static int ! write_spell_prefcond(FILE *fd, garray_T *gap) { int i; char_u *p; int len; int totlen; - size_t x UNUSED = 1; // collect return value of fwrite() if (fd != NULL) put_bytes(fd, (long_u)gap->ga_len, 2); // --- 6567,6581 ---- /* * Write the table with prefix conditions to the .spl file. ! * When "fd" is NULL only count the length of what is written and return it. */ static int ! write_spell_prefcond(FILE *fd, garray_T *gap, size_t *fwv) { int i; char_u *p; int len; int totlen; if (fd != NULL) put_bytes(fd, (long_u)gap->ga_len, 2); // *************** *** 6593,6599 **** if (fd != NULL) { fputc(len, fd); ! x &= fwrite(p, (size_t)len, (size_t)1, fd); } totlen += len; } --- 6592,6598 ---- if (fd != NULL) { fputc(len, fd); ! *fwv &= fwrite(p, (size_t)len, (size_t)1, fd); } totlen += len; } *************** *** 6604,6610 **** return totlen; } - /* * Use map string "map" for languages "lp". */ --- 6603,6608 ---- *** ../vim-8.2.3776/src/version.c 2021-12-10 20:15:11.701972267 +0000 --- src/version.c 2021-12-10 20:38:00.851926682 +0000 *************** *** 755,756 **** --- 755,758 ---- { /* Add new patch number below this line */ + /**/ + 3777, /**/ -- I have a drinking problem -- I can't afford it. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///