mirror of
https://github.com/neovim/neovim.git
synced 2025-09-28 05:58:33 +00:00
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)
4ad739fc05
This commit is contained in:
@@ -5765,14 +5765,14 @@ cleanup_suggestions (
|
|||||||
)
|
)
|
||||||
FUNC_ATTR_NONNULL_ALL
|
FUNC_ATTR_NONNULL_ALL
|
||||||
{
|
{
|
||||||
suggest_T *stp = &SUG(*gap, 0);
|
|
||||||
|
|
||||||
if (gap->ga_len > 0) {
|
if (gap->ga_len > 0) {
|
||||||
// Sort the list.
|
// Sort the list.
|
||||||
qsort(gap->ga_data, (size_t)gap->ga_len, sizeof(suggest_T), sug_compare);
|
qsort(gap->ga_data, (size_t)gap->ga_len, sizeof(suggest_T), sug_compare);
|
||||||
|
|
||||||
// Truncate the list to the number of suggestions that will be displayed.
|
// Truncate the list to the number of suggestions that will be displayed.
|
||||||
if (gap->ga_len > keep) {
|
if (gap->ga_len > keep) {
|
||||||
|
suggest_T *const stp = &SUG(*gap, 0);
|
||||||
|
|
||||||
for (int i = keep; i < gap->ga_len; i++) {
|
for (int i = keep; i < gap->ga_len; i++) {
|
||||||
xfree(stp[i].st_word);
|
xfree(stp[i].st_word);
|
||||||
}
|
}
|
||||||
|
@@ -984,15 +984,17 @@ nextone:
|
|||||||
static char_u *read_cnt_string(FILE *fd, int cnt_bytes, int *cntp)
|
static char_u *read_cnt_string(FILE *fd, int cnt_bytes, int *cntp)
|
||||||
{
|
{
|
||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
int i;
|
|
||||||
char_u *str;
|
char_u *str;
|
||||||
|
|
||||||
// read the length bytes, MSB first
|
// read the length bytes, MSB first
|
||||||
for (i = 0; i < cnt_bytes; ++i)
|
for (int i = 0; i < cnt_bytes; i++) {
|
||||||
cnt = (cnt << 8) + getc(fd);
|
const int c = getc(fd);
|
||||||
if (cnt < 0) {
|
|
||||||
*cntp = SP_TRUNCERROR;
|
if (c == EOF) {
|
||||||
return NULL;
|
*cntp = SP_TRUNCERROR;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
cnt = (cnt << 8) + (unsigned)c;
|
||||||
}
|
}
|
||||||
*cntp = cnt;
|
*cntp = cnt;
|
||||||
if (cnt == 0)
|
if (cnt == 0)
|
||||||
|
Reference in New Issue
Block a user