diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/eval/typval.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c index 47c3551a56..25b2a20bac 100644 --- a/src/nvim/eval/typval.c +++ b/src/nvim/eval/typval.c @@ -2471,11 +2471,13 @@ void tv_dict_extend(dict_T *const d1, dict_T *const d2, const char *const action } if (di1 == NULL) { if (*action == 'm') { - // cheap way to move a dict item from "d2" to "d1" + // Cheap way to move a dict item from "d2" to "d1". + // If dict_add() fails then "d2" won't be empty. dictitem_T *const new_di = di2; - tv_dict_add(d1, new_di); - hash_remove(&d2->dv_hashtab, hi2); - tv_dict_watcher_notify(d1, (const char *)new_di->di_key, &new_di->di_tv, NULL); + if (tv_dict_add(d1, new_di) == OK) { + hash_remove(&d2->dv_hashtab, hi2); + tv_dict_watcher_notify(d1, (const char *)new_di->di_key, &new_di->di_tv, NULL); + } } else { dictitem_T *const new_di = tv_dict_item_copy(di2); if (tv_dict_add(d1, new_di) == FAIL) { |