diff options
author | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2020-09-02 22:22:15 -0400 |
---|---|---|
committer | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2020-09-02 22:44:21 -0400 |
commit | 5fcdb630253b8d71fd30a2259f72aeb27e1676e0 (patch) | |
tree | 1a891b01dbca622ed8e4cbb5930d1a6425d146ba /src/nvim/spellfile.c | |
parent | b9430fe28ef8c5a865b3bee5c7f523abc3b1947a (diff) | |
download | rneovim-5fcdb630253b8d71fd30a2259f72aeb27e1676e0.tar.gz rneovim-5fcdb630253b8d71fd30a2259f72aeb27e1676e0.tar.bz2 rneovim-5fcdb630253b8d71fd30a2259f72aeb27e1676e0.zip |
vim-patch:8.2.1564: a few remaining errors from ubsan
Problem: A few remaining errors from ubsan.
Solution: Avoid the warnings. (Dominique Pellé, closes vim/vim#6837)
https://github.com/vim/vim/commit/4ad739fc053c1666d07ba1cf59be26cb1c3e52d7
Diffstat (limited to 'src/nvim/spellfile.c')
-rw-r--r-- | src/nvim/spellfile.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/nvim/spellfile.c b/src/nvim/spellfile.c index c2212cf767..09d8646c6d 100644 --- a/src/nvim/spellfile.c +++ b/src/nvim/spellfile.c @@ -984,15 +984,17 @@ nextone: static char_u *read_cnt_string(FILE *fd, int cnt_bytes, int *cntp) { int cnt = 0; - int i; char_u *str; // read the length bytes, MSB first - for (i = 0; i < cnt_bytes; ++i) - cnt = (cnt << 8) + getc(fd); - if (cnt < 0) { - *cntp = SP_TRUNCERROR; - return NULL; + for (int i = 0; i < cnt_bytes; i++) { + const int c = getc(fd); + + if (c == EOF) { + *cntp = SP_TRUNCERROR; + return NULL; + } + cnt = (cnt << 8) + (unsigned)c; } *cntp = cnt; if (cnt == 0) |