summaryrefslogtreecommitdiff
path: root/src/dict.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2018-07-08 17:19:02 +0200
committerBram Moolenaar <Bram@vim.org>2018-07-08 17:19:02 +0200
commitc89d4b35300b98cf68b14c89c8e1add51bd857e3 (patch)
tree467d753ac74270da629887f484f797509696d302 /src/dict.c
parente0be167a805fd547c25ec1ec97fd4c7f13046236 (diff)
downloadvim-git-c89d4b35300b98cf68b14c89c8e1add51bd857e3.tar.gz
patch 8.1.0167: lock flag in new dictitem is reset in many placesv8.1.0167
Problem: Lock flag in new dictitem is reset in many places. Solution: Always reset the lock flag.
Diffstat (limited to 'src/dict.c')
-rw-r--r--src/dict.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/dict.c b/src/dict.c
index e1f7fa23e..c359e6f0f 100644
--- a/src/dict.c
+++ b/src/dict.c
@@ -188,7 +188,8 @@ dict_free_items(int copyID)
/*
* Allocate a Dictionary item.
* The "key" is copied to the new item.
- * Note that the value of the item "di_tv" still needs to be initialized!
+ * Note that the type and value of the item "di_tv" still needs to be
+ * initialized!
* Returns NULL when out of memory.
*/
dictitem_T *
@@ -201,6 +202,7 @@ dictitem_alloc(char_u *key)
{
STRCPY(di->di_key, key);
di->di_flags = DI_FLAGS_ALLOC;
+ di->di_tv.v_lock = 0;
}
return di;
}
@@ -338,7 +340,6 @@ dict_add_number(dict_T *d, char *key, varnumber_T nr)
item = dictitem_alloc((char_u *)key);
if (item == NULL)
return FAIL;
- item->di_tv.v_lock = 0;
item->di_tv.v_type = VAR_NUMBER;
item->di_tv.vval.v_number = nr;
if (dict_add(d, item) == FAIL)
@@ -361,7 +362,6 @@ dict_add_string(dict_T *d, char *key, char_u *str)
item = dictitem_alloc((char_u *)key);
if (item == NULL)
return FAIL;
- item->di_tv.v_lock = 0;
item->di_tv.v_type = VAR_STRING;
item->di_tv.vval.v_string = str != NULL ? vim_strsave(str) : NULL;
if (dict_add(d, item) == FAIL)
@@ -384,7 +384,6 @@ dict_add_list(dict_T *d, char *key, list_T *list)
item = dictitem_alloc((char_u *)key);
if (item == NULL)
return FAIL;
- item->di_tv.v_lock = 0;
item->di_tv.v_type = VAR_LIST;
item->di_tv.vval.v_list = list;
++list->lv_refcount;
@@ -408,7 +407,6 @@ dict_add_dict(dict_T *d, char *key, dict_T *dict)
item = dictitem_alloc((char_u *)key);
if (item == NULL)
return FAIL;
- item->di_tv.v_lock = 0;
item->di_tv.v_type = VAR_DICT;
item->di_tv.vval.v_dict = dict;
++dict->dv_refcount;