commit 65d95fa41530bfc85ba5dd6ae10201e6b788e4a3
parent e339376cca2faf18da7a03f93958ef926f856643
Author: zeertzjq <zeertzjq@outlook.com>
Date: Wed, 23 Nov 2022 19:56:50 +0800
vim-patch:9.0.0926: Coverity warns for not using return value of dict_add()
Problem: Coverity warns for not using return value of dict_add().
Solution: When dict_add() fails then don't call hash_remove().
https://github.com/vim/vim/commit/bc222152d8dea252aa5f1fa24b5536ed269feb92
N/A patches for version.c:
vim-patch:9.0.0927: Coverity warns for using a NULL pointer
Problem: Coverity warns for using a NULL pointer.
Solution: Check for memory allocaion failure.
https://github.com/vim/vim/commit/96cbbe29debba25d7eec8d01955c5ac01f5c420d
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Diffstat:
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git 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) {