0
0
mirror of https://github.com/vim/vim.git synced 2025-09-24 03:44:06 -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,12 +816,16 @@ read_cnt_string(FILE *fd, int cnt_bytes, int *cntp)
// read the length bytes, MSB first // read the length bytes, MSB first
for (i = 0; i < cnt_bytes; ++i) for (i = 0; i < cnt_bytes; ++i)
cnt = (cnt << 8) + (unsigned)getc(fd); {
if (cnt < 0) int c = getc(fd);
if (c == EOF)
{ {
*cntp = SP_TRUNCERROR; *cntp = SP_TRUNCERROR;
return NULL; return NULL;
} }
cnt = (cnt << 8) + (unsigned)c;
}
*cntp = cnt; *cntp = cnt;
if (cnt == 0) if (cnt == 0)
return NULL; // nothing to read, return NULL return NULL; // nothing to read, return NULL

View File

@@ -3731,9 +3731,6 @@ cleanup_suggestions(
int maxscore, int maxscore,
int keep) // nr of suggestions to keep int keep) // nr of suggestions to keep
{ {
suggest_T *stp = &SUG(*gap, 0);
int i;
if (gap->ga_len > 0) if (gap->ga_len > 0)
{ {
// Sort the list. // Sort the list.
@@ -3744,6 +3741,9 @@ cleanup_suggestions(
// displayed. // displayed.
if (gap->ga_len > keep) if (gap->ga_len > keep)
{ {
int i;
suggest_T *stp = &SUG(*gap, 0);
for (i = keep; i < gap->ga_len; ++i) for (i = keep; i < gap->ga_len; ++i)
vim_free(stp[i].st_word); vim_free(stp[i].st_word);
gap->ga_len = keep; gap->ga_len = keep;

View File

@@ -754,6 +754,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1564,
/**/ /**/
1563, 1563,
/**/ /**/

View File

@@ -2183,7 +2183,8 @@ write_viminfo_filemarks(FILE *fp)
xfmark_T *vi_fm; xfmark_T *vi_fm;
fm = idx >= 0 ? &curwin->w_jumplist[idx] : NULL; fm = idx >= 0 ? &curwin->w_jumplist[idx] : NULL;
vi_fm = vi_idx < vi_jumplist_len ? &vi_jumplist[vi_idx] : NULL; vi_fm = (vi_jumplist != NULL && vi_idx < vi_jumplist_len)
? &vi_jumplist[vi_idx] : NULL;
if (fm == NULL && vi_fm == NULL) if (fm == NULL && vi_fm == NULL)
break; break;
if (fm == NULL || (vi_fm != NULL && fm->time_set < vi_fm->time_set)) if (fm == NULL || (vi_fm != NULL && fm->time_set < vi_fm->time_set))