diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-11-23 19:56:50 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2022-11-23 19:59:43 +0800 |
commit | 65d95fa41530bfc85ba5dd6ae10201e6b788e4a3 (patch) | |
tree | ff43e67b67a38e7d8d160cbfa4a6f43b10a84179 /src | |
parent | e339376cca2faf18da7a03f93958ef926f856643 (diff) | |
download | rneovim-65d95fa41530bfc85ba5dd6ae10201e6b788e4a3.tar.gz rneovim-65d95fa41530bfc85ba5dd6ae10201e6b788e4a3.tar.bz2 rneovim-65d95fa41530bfc85ba5dd6ae10201e6b788e4a3.zip |
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 (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) { |