Skip to content

Commit

Permalink
patch 8.2.1843: Netbeans: with huge buffer number memory allocation m…
Browse files Browse the repository at this point in the history
…ay fail

Problem:    Netbeans: with huge buffer number memory allocation may fail.
Solution:   Check for size overflow.
  • Loading branch information
brammool committed Oct 13, 2020
1 parent 21cbe17 commit b9616af
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/netbeans.c
Expand Up @@ -674,11 +674,19 @@ nb_get_buf(int bufno)
{
if (bufno >= buf_list_size) // grow list
{
nbbuf_T *t_buf_list = buf_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);
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -750,6 +750,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1843,
/**/
1842,
/**/
Expand Down

0 comments on commit b9616af

Please sign in to comment.