fix(PVS/V1028): prevent possible overflow #16023

Full warning: "Possible overflow. Consider casting operands, not the
result."

https://pvs-studio.com/en/docs/warnings/v1028/
This commit is contained in:
dundargoc 2021-10-18 02:11:23 +02:00 committed by GitHub
parent ffc28dcbdb
commit aff444659e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -467,7 +467,7 @@ static mtnode_t *merge_node(MarkTree *b, mtnode_t *p, int i)
unrelative(x->key[x->n].pos, &x->key[x->n+1+k].pos);
}
if (x->level) {
memmove(&x->ptr[x->n+1], y->ptr, (size_t)(y->n + 1) * sizeof(mtnode_t *));
memmove(&x->ptr[x->n+1], y->ptr, ((size_t)y->n + 1) * sizeof(mtnode_t *));
for (int k = 0; k < y->n+1; k++) {
x->ptr[x->n+k+1]->parent = x;
}
@ -489,7 +489,7 @@ static void pivot_right(MarkTree *b, mtnode_t *p, int i)
mtnode_t *x = p->ptr[i], *y = p->ptr[i+1];
memmove(&y->key[1], y->key, (size_t)y->n * sizeof(mtkey_t));
if (y->level) {
memmove(&y->ptr[1], y->ptr, (size_t)(y->n + 1) * sizeof(mtnode_t *));
memmove(&y->ptr[1], y->ptr, ((size_t)y->n + 1) * sizeof(mtnode_t *));
}
y->key[0] = p->key[i];
refkey(b, y, 0);

View File

@ -3510,7 +3510,7 @@ static char_u *set_chars_option(win_T *wp, char_u **varp, bool set)
xfree(wp->w_p_lcs_chars.multispace);
}
if (multispace_len > 0) {
wp->w_p_lcs_chars.multispace = xmalloc((size_t)(multispace_len + 1) * sizeof(int));
wp->w_p_lcs_chars.multispace = xmalloc(((size_t)multispace_len + 1) * sizeof(int));
wp->w_p_lcs_chars.multispace[multispace_len] = NUL;
} else {
wp->w_p_lcs_chars.multispace = NULL;