Permalink
Browse files

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)
  • Loading branch information...
brammool committed Mar 14, 2017
1 parent 88d298a commit 42f45b850df93b806ef44f3025aecedfffb9ae01
Showing with 4 additions and 2 deletions.
  1. +2 −2 src/dict.c
  2. +2 −0 src/version.c
View
@@ -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
@@ -764,6 +764,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 458,
/**/
457,
/**/

0 comments on commit 42f45b8

Please sign in to comment.