diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-09-02 10:25:45 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-09-02 10:25:45 +0200 |
commit | 4ad739fc053c1666d07ba1cf59be26cb1c3e52d7 (patch) | |
tree | 66485dc142df679ab7c8091c2e6f14c7bc9608cb /src/spellfile.c | |
parent | 6f84b6db10ab86bca85e33f3fc6ee735eec8bbe5 (diff) | |
download | vim-git-4ad739fc053c1666d07ba1cf59be26cb1c3e52d7.tar.gz |
patch 8.2.1564: a few remaining errors from ubsanv8.2.1564
Problem: A few remaining errors from ubsan.
Solution: Avoid the warnings. (Dominique Pellé, closes #6837)
Diffstat (limited to 'src/spellfile.c')
-rw-r--r-- | src/spellfile.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/spellfile.c b/src/spellfile.c index d5ec3fead..12dedd6c5 100644 --- a/src/spellfile.c +++ b/src/spellfile.c @@ -816,11 +816,15 @@ read_cnt_string(FILE *fd, int cnt_bytes, int *cntp) // read the length bytes, MSB first for (i = 0; i < cnt_bytes; ++i) - cnt = (cnt << 8) + (unsigned)getc(fd); - if (cnt < 0) { - *cntp = SP_TRUNCERROR; - return NULL; + int c = getc(fd); + + if (c == EOF) + { + *cntp = SP_TRUNCERROR; + return NULL; + } + cnt = (cnt << 8) + (unsigned)c; } *cntp = cnt; if (cnt == 0) |