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:
@@ -675,10 +675,18 @@ nb_get_buf(int bufno)
|
|||||||
if (bufno >= buf_list_size) // grow list
|
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;
|
incr = bufno - buf_list_size + 90;
|
||||||
buf_list_size += incr;
|
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)
|
if (buf_list == NULL)
|
||||||
{
|
{
|
||||||
vim_free(t_buf_list);
|
vim_free(t_buf_list);
|
||||||
|
@@ -750,6 +750,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1843,
|
||||||
/**/
|
/**/
|
||||||
1842,
|
1842,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user