0
0
mirror of https://github.com/vim/vim.git synced 2025-09-29 04:34:16 -04:00

patch 8.2.1564: a few remaining errors from ubsan

Problem:    A few remaining errors from ubsan.
Solution:   Avoid the warnings. (Dominique Pellé, closes #6837)
This commit is contained in:
Bram Moolenaar
2020-09-02 10:25:45 +02:00
parent 6f84b6db10
commit 4ad739fc05
4 changed files with 15 additions and 8 deletions

View File

@@ -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)