From aea70b4404399d353e1df0bd73ef344f5559843a Mon Sep 17 00:00:00 2001 From: Nick Neisen Date: Wed, 16 May 2018 19:18:35 -0600 Subject: coverity/13709: spell_add_word: handle failed fseek() Check the return status after removing a duplicate word. Add a log for a nonzero return status. --- src/nvim/spellfile.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/spellfile.c b/src/nvim/spellfile.c index dab9a2aacd..b844fd9ab8 100644 --- a/src/nvim/spellfile.c +++ b/src/nvim/spellfile.c @@ -5368,8 +5368,9 @@ spell_add_word ( // doesn't work for all systems, close the file first. fclose(fd); fd = mch_fopen((char *)fname, "r+"); - if (fd == NULL) + if (fd == NULL) { break; + } if (fseek(fd, fpos, SEEK_SET) == 0) { fputc('#', fd); if (undo) { @@ -5378,7 +5379,9 @@ spell_add_word ( len, word, NameBuff); } } - fseek(fd, fpos_next, SEEK_SET); + if (fseek(fd, fpos_next, SEEK_SET) <= 0) { + break; + } } } if (fd != NULL) -- cgit