Mercurial > vim
changeset 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 | d93cb88886cd |
children | 8b0a2216a70e |
files | src/spellfile.c src/spellsuggest.c src/version.c src/viminfo.c |
diffstat | 4 files changed, 15 insertions(+), 8 deletions(-) [+] |
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)
--- a/src/spellsuggest.c +++ b/src/spellsuggest.c @@ -3731,9 +3731,6 @@ cleanup_suggestions( int maxscore, int keep) // nr of suggestions to keep { - suggest_T *stp = &SUG(*gap, 0); - int i; - if (gap->ga_len > 0) { // Sort the list. @@ -3744,6 +3741,9 @@ cleanup_suggestions( // displayed. if (gap->ga_len > keep) { + int i; + suggest_T *stp = &SUG(*gap, 0); + for (i = keep; i < gap->ga_len; ++i) vim_free(stp[i].st_word); gap->ga_len = keep;
--- a/src/version.c +++ b/src/version.c @@ -755,6 +755,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1564, +/**/ 1563, /**/ 1562,
--- a/src/viminfo.c +++ b/src/viminfo.c @@ -2183,7 +2183,8 @@ write_viminfo_filemarks(FILE *fp) xfmark_T *vi_fm; 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) break; if (fm == NULL || (vi_fm != NULL && fm->time_set < vi_fm->time_set))