summaryrefslogtreecommitdiff
path: root/src/dict.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2017-03-14 22:17:14 +0100
committerBram Moolenaar <Bram@vim.org>2017-03-14 22:17:14 +0100
commit42f45b850df93b806ef44f3025aecedfffb9ae01 (patch)
tree1f3af227f1dd63429598d15463b6c5130c6f0495 /src/dict.c
parent88d298aed8682eac872ebfe40df3112a6acd83e8 (diff)
downloadvim-git-42f45b850df93b806ef44f3025aecedfffb9ae01.tar.gz
patch 8.0.0458: potential crash if adding list or dict to dict failsv8.0.0458
Problem: Potential crash if adding list or dict to dict fails. Solution: Make sure the reference count is correct. (Nikolai Pavlov, closes #1555)
Diffstat (limited to 'src/dict.c')
-rw-r--r--src/dict.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/dict.c b/src/dict.c
index 70743059e..a26419b6d 100644
--- a/src/dict.c
+++ b/src/dict.c
@@ -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;
}