Mercurial > vim
diff src/spellfile.c @ 22029:2d6d70a913c1 v8.2.1564
patch 8.2.1564: a few remaining errors from ubsan
Commit: https://github.com/vim/vim/commit/4ad739fc053c1666d07ba1cf59be26cb1c3e52d7
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Sep 2 10:25:45 2020 +0200
patch 8.2.1564: a few remaining errors from ubsan
Problem: A few remaining errors from ubsan.
Solution: Avoid the warnings. (Dominique Pell?, closes https://github.com/vim/vim/issues/6837)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 02 Sep 2020 10:30:05 +0200 |
parents | 514d622473af |
children | f33de1c1eb4a |
line wrap: on
line diff
--- a/src/spellfile.c +++ b/src/spellfile.c @@ -816,11 +816,15 @@ read_cnt_string(FILE *fd, int cnt_bytes, // 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)