forked from aniani/vim
patch 8.1.1825: allocating more memory than needed for extended structs
Problem: Allocating more memory than needed for extended structs. Solution: Use offsetof() instead of sizeof(). (Dominique Pelle, closes #4785)
This commit is contained in:
@@ -210,7 +210,7 @@ dictitem_alloc(char_u *key)
|
|||||||
{
|
{
|
||||||
dictitem_T *di;
|
dictitem_T *di;
|
||||||
|
|
||||||
di = alloc(sizeof(dictitem_T) + STRLEN(key));
|
di = alloc(offsetof(dictitem_T, di_key) + STRLEN(key) + 1);
|
||||||
if (di != NULL)
|
if (di != NULL)
|
||||||
{
|
{
|
||||||
STRCPY(di->di_key, key);
|
STRCPY(di->di_key, key);
|
||||||
@@ -228,7 +228,7 @@ dictitem_copy(dictitem_T *org)
|
|||||||
{
|
{
|
||||||
dictitem_T *di;
|
dictitem_T *di;
|
||||||
|
|
||||||
di = alloc(sizeof(dictitem_T) + STRLEN(org->di_key));
|
di = alloc(offsetof(dictitem_T, di_key) + STRLEN(org->di_key) + 1);
|
||||||
if (di != NULL)
|
if (di != NULL)
|
||||||
{
|
{
|
||||||
STRCPY(di->di_key, org->di_key);
|
STRCPY(di->di_key, org->di_key);
|
||||||
|
@@ -769,6 +769,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 */
|
||||||
|
/**/
|
||||||
|
1825,
|
||||||
/**/
|
/**/
|
||||||
1824,
|
1824,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user