aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2021-12-11 09:25:09 +0100
committerGitHub <noreply@github.com>2021-12-11 09:25:09 +0100
commite93b26eb0e476ab0df920dfe3fbceef686f56a7d (patch)
treeab950b808c0e7385c37f18b1cacee3ff8480debd
parenta415a7e672329c63cebe1a597246c393fbdc615c (diff)
parentd23a5da890f106bf45898801000904d06c5a045a (diff)
downloadrneovim-e93b26eb0e476ab0df920dfe3fbceef686f56a7d.tar.gz
rneovim-e93b26eb0e476ab0df920dfe3fbceef686f56a7d.tar.bz2
rneovim-e93b26eb0e476ab0df920dfe3fbceef686f56a7d.zip
Merge pull request #16613 from bfredl/vim-patch-8.2.3777
vim-patch:8.2.3777: spell file write error not checked
-rw-r--r--src/nvim/spellfile.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/nvim/spellfile.c b/src/nvim/spellfile.c
index 8069549cc6..42bb3c61a5 100644
--- a/src/nvim/spellfile.c
+++ b/src/nvim/spellfile.c
@@ -4446,10 +4446,10 @@ static int write_vim_spell(spellinfo_T *spin, char_u *fname)
putc(SN_PREFCOND, fd); // <sectionID>
putc(SNF_REQUIRED, fd); // <sectionflags>
- size_t l = (size_t)write_spell_prefcond(NULL, &spin->si_prefcond);
+ size_t l = (size_t)write_spell_prefcond(NULL, &spin->si_prefcond, &fwv);
put_bytes(fd, l, 4); // <sectionlen>
- write_spell_prefcond(fd, &spin->si_prefcond);
+ write_spell_prefcond(fd, &spin->si_prefcond, &fwv);
}
// SN_REP: <repcount> <rep> ...
@@ -5793,7 +5793,7 @@ static int set_spell_finish(spelltab_T *new_st)
// 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)
+static int write_spell_prefcond(FILE *fd, garray_T *gap, size_t *fwv)
{
assert(gap->ga_len >= 0);
@@ -5801,8 +5801,7 @@ static int write_spell_prefcond(FILE *fd, garray_T *gap)
put_bytes(fd, (uintmax_t)gap->ga_len, 2); // <prefcondcnt>
}
size_t totlen = 2 + (size_t)gap->ga_len; // <prefcondcnt> and <condlen> bytes
- size_t x = 1; // collect return value of fwrite()
- for (int i = 0; i < gap->ga_len; ++i) {
+ for (int i = 0; i < gap->ga_len; i++) {
// <prefcond> : <condlen> <condstr>
char_u *p = ((char_u **)gap->ga_data)[i];
if (p != NULL) {
@@ -5810,7 +5809,7 @@ static int write_spell_prefcond(FILE *fd, garray_T *gap)
if (fd != NULL) {
assert(len <= INT_MAX);
fputc((int)len, fd);
- x &= fwrite(p, len, 1, fd);
+ *fwv &= fwrite(p, len, 1, fd);
}
totlen += len;
} else if (fd != NULL) {