0
0
mirror of https://github.com/vim/vim.git synced 2025-07-04 23:07:33 -04:00

patch 8.0.0458: potential crash if adding list or dict to dict fails

Problem:    Potential crash if adding list or dict to dict fails.
Solution:   Make sure the reference count is correct. (Nikolai Pavlov, closes
            #1555)
This commit is contained in:
Bram Moolenaar 2017-03-14 22:17:14 +01:00
parent 88d298aed8
commit 42f45b850d
2 changed files with 4 additions and 2 deletions

View File

@ -356,12 +356,12 @@ dict_add_list(dict_T *d, char *key, list_T *list)
item->di_tv.v_lock = 0;
item->di_tv.v_type = VAR_LIST;
item->di_tv.vval.v_list = list;
++list->lv_refcount;
if (dict_add(d, item) == FAIL)
{
dictitem_free(item);
return FAIL;
}
++list->lv_refcount;
return OK;
}
@ -380,12 +380,12 @@ dict_add_dict(dict_T *d, char *key, dict_T *dict)
item->di_tv.v_lock = 0;
item->di_tv.v_type = VAR_DICT;
item->di_tv.vval.v_dict = dict;
++dict->dv_refcount;
if (dict_add(d, item) == FAIL)
{
dictitem_free(item);
return FAIL;
}
++dict->dv_refcount;
return OK;
}

View File

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