summaryrefslogtreecommitdiffstats
path: root/src/dict.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-11-23 11:34:01 +0000
committerBram Moolenaar <Bram@vim.org>2022-11-23 11:34:01 +0000
commitbc222152d8dea252aa5f1fa24b5536ed269feb92 (patch)
treebab73ad7c0b1a03b1cd761b90711adb8e18f29c5 /src/dict.c
parentdf3c0eb41e1f48596c85af88b42fed22e3cca328 (diff)
patch 9.0.0926: Coverity warns for not using return value of dict_add()v9.0.0926
Problem: Coverity warns for not using return value of dict_add(). Solution: When dict_add() fails then don't call hash_remove().
Diffstat (limited to 'src/dict.c')
-rw-r--r--src/dict.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/dict.c b/src/dict.c
index 30264a9134..ffd5d381ec 100644
--- a/src/dict.c
+++ b/src/dict.c
@@ -1122,10 +1122,11 @@ dict_extend(dict_T *d1, dict_T *d2, char_u *action, char *func_name)
{
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.
di1 = HI2DI(hi2);
- dict_add(d1, di1);
- hash_remove(&d2->dv_hashtab, hi2);
+ if (dict_add(d1, di1) == OK)
+ hash_remove(&d2->dv_hashtab, hi2);
}
else
{