summaryrefslogtreecommitdiffstats
path: root/src/dict.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-04-23 13:38:02 +0200
committerBram Moolenaar <Bram@vim.org>2020-04-23 13:38:02 +0200
commitea04a6e8baff2f27da7cdd54bf70a5525994f76d (patch)
treed8578e5bec3f99d462191ba6eb49f83c60211181 /src/dict.c
parentdb950e4c0318c084c31bc7b50665284f4a47c285 (diff)
patch 8.2.0619: null dict is not handled like an empty dictv8.2.0619
Problem: Null dict is not handled like an empty dict. Solution: Fix the code and add tests. (Yegappan Lakshmanan, closes #5968)
Diffstat (limited to 'src/dict.c')
-rw-r--r--src/dict.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/dict.c b/src/dict.c
index 1a928a35f2..88bd0e21c6 100644
--- a/src/dict.c
+++ b/src/dict.c
@@ -977,14 +977,15 @@ dict_equal(
dictitem_T *item2;
int todo;
- if (d1 == NULL && d2 == NULL)
- return TRUE;
- if (d1 == NULL || d2 == NULL)
- return FALSE;
if (d1 == d2)
return TRUE;
if (dict_len(d1) != dict_len(d2))
return FALSE;
+ if (dict_len(d1) == 0)
+ // empty and NULL dicts are considered equal
+ return TRUE;
+ if (d1 == NULL || d2 == NULL)
+ return FALSE;
todo = (int)d1->dv_hashtab.ht_used;
for (hi = d1->dv_hashtab.ht_array; todo > 0; ++hi)