0
0
mirror of https://github.com/vim/vim.git synced 2025-09-29 04:34:16 -04:00

patch 8.2.1843: Netbeans: with huge buffer number memory allocation may fail

Problem:    Netbeans: with huge buffer number memory allocation may fail.
Solution:   Check for size overflow.
This commit is contained in:
Bram Moolenaar
2020-10-13 21:11:13 +02:00
parent 21cbe175ee
commit b9616af23f
2 changed files with 12 additions and 2 deletions

View File

@@ -675,10 +675,18 @@ nb_get_buf(int bufno)
if (bufno >= buf_list_size) // grow list
{
nbbuf_T *t_buf_list = buf_list;
size_t bufsize;
incr = bufno - buf_list_size + 90;
buf_list_size += incr;
buf_list = vim_realloc(buf_list, buf_list_size * sizeof(nbbuf_T));
bufsize = buf_list_size * sizeof(nbbuf_T);
if (bufsize == 0 || bufsize / sizeof(nbbuf_T)
!= (size_t)buf_list_size)
{
// list size overflow, bail out
return NULL;
}
buf_list = vim_realloc(buf_list, bufsize);
if (buf_list == NULL)
{
vim_free(t_buf_list);

View File

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