Merge pull request #40559 from zeertzjq/vim-9.2.0770

vim-patch:9.2.{0770,0771}
This commit is contained in:
zeertzjq
2026-07-03 15:47:02 +08:00
committed by GitHub

View File

@@ -2494,11 +2494,14 @@ int tv_dict_add_list(dict_T *const d, const char *const key, const size_t key_le
item->di_tv.v_type = VAR_LIST;
item->di_tv.vval.v_list = list;
tv_list_ref(list);
if (tv_dict_add(d, item) == FAIL) {
// Detach "list" so tv_dict_item_free() does not unref it: on failure
// ownership stays with the caller.
item->di_tv.vval.v_list = NULL;
tv_dict_item_free(item);
return FAIL;
}
tv_list_ref(list);
return OK;
}
@@ -2537,11 +2540,14 @@ int tv_dict_add_dict(dict_T *const d, const char *const key, const size_t key_le
item->di_tv.v_type = VAR_DICT;
item->di_tv.vval.v_dict = dict;
dict->dv_refcount++;
if (tv_dict_add(d, item) == FAIL) {
// Detach "dict" so tv_dict_item_free() does not unref it: on failure
// ownership stays with the caller.
item->di_tv.vval.v_dict = NULL;
tv_dict_item_free(item);
return FAIL;
}
dict->dv_refcount++;
return OK;
}