0
0
mirror of https://github.com/vim/vim.git synced 2025-09-27 04:14:06 -04:00

patch 8.2.4255: theoretical computation overflow

Problem:    Theoretical computation overflow.
Solution:   Perform multiplication in a wider type. (closes #9657)
This commit is contained in:
=?UTF-8?q?Dundar=20G=C3=B6c?=
2022-01-29 15:19:23 +00:00
committed by Bram Moolenaar
parent f12b7815f6
commit d5cec1f1f0
11 changed files with 28 additions and 23 deletions

View File

@@ -737,11 +737,11 @@ ga_grow_inner(garray_T *gap, int n)
if (n < gap->ga_len / 2)
n = gap->ga_len / 2;
new_len = gap->ga_itemsize * (gap->ga_len + n);
new_len = (size_t)gap->ga_itemsize * (gap->ga_len + n);
pp = vim_realloc(gap->ga_data, new_len);
if (pp == NULL)
return FAIL;
old_len = gap->ga_itemsize * gap->ga_maxlen;
old_len = (size_t)gap->ga_itemsize * gap->ga_maxlen;
vim_memset(pp + old_len, 0, new_len - old_len);
gap->ga_maxlen = gap->ga_len + n;
gap->ga_data = pp;