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);                          // <sectionID>
        putc(SNF_REQUIRED, fd);                         // <sectionflags>
  
!       l = write_spell_prefcond(NULL, &spin->si_prefcond);
        put_bytes(fd, (long_u)l, 4);                    // <sectionlen>
  
!       write_spell_prefcond(fd, &spin->si_prefcond);
      }
  
      // SN_REP: <repcount> <rep> ...
--- 4977,4986 ----
        putc(SN_PREFCOND, fd);                          // <sectionID>
        putc(SNF_REQUIRED, fd);                         // <sectionflags>
  
!       l = write_spell_prefcond(NULL, &spin->si_prefcond, &fwv);
        put_bytes(fd, (long_u)l, 4);                    // <sectionlen>
  
!       write_spell_prefcond(fd, &spin->si_prefcond, &fwv);
      }
  
      // SN_REP: <repcount> <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);      // <prefcondcnt>
--- 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);      // <prefcondcnt>
***************
*** 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 -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20211210203945.3C0BA1C09BB%40moolenaar.net.

Raspunde prin e-mail lui