summaryrefslogtreecommitdiffstats
path: root/libglusterfs
diff options
context:
space:
mode:
authorXavi Hernandez <xhernandez@redhat.com>2018-04-12 23:31:37 +0200
committerXavi Hernandez <xhernandez@redhat.com>2018-04-18 08:34:20 +0000
commit52d1b36e3738b7117c5ecf0a83ceba1438fad68a (patch)
treef155b4473c4f4123429fa2886f4dce56aa6e1c2d /libglusterfs
parent9a1ae47c8d60836ae0628a04a153f28c1085c0e8 (diff)
libglusterfs: fix comparison of a NULL dict with a non-NULL dict
Function are_dicts_equal() had a bug when the first argument was NULL and the second one wasn't NULL. In this case it incorrectly returned that the dicts were different when they could be equal. Fixes: bz#1566732 Change-Id: I0fc245c2e7d1395865a76405dbd05e5d34db3273 Signed-off-by: Xavi Hernandez <xhernandez@redhat.com>
Diffstat (limited to 'libglusterfs')
-rw-r--r--libglusterfs/src/dict.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/libglusterfs/src/dict.c b/libglusterfs/src/dict.c
index 0f9632160cc..bd22477f2c4 100644
--- a/libglusterfs/src/dict.c
+++ b/libglusterfs/src/dict.c
@@ -207,17 +207,17 @@ are_dicts_equal (dict_t *one, dict_t *two,
if (!match)
match = dict_match_everything;
- cmp.dict = two;
- cmp.value_ignore = value_ignore;
- if (!two) {
- num_matches1 = dict_foreach_match (one, match, NULL,
- dict_null_foreach_fn, NULL);
+ if ((one == NULL) || (two == NULL)) {
+ num_matches1 = dict_foreach_match(one ? one : two, match, NULL,
+ dict_null_foreach_fn, NULL);
goto done;
- } else {
- num_matches1 = dict_foreach_match (one, match, NULL,
- key_value_cmp, &cmp);
}
+ cmp.dict = two;
+ cmp.value_ignore = value_ignore;
+ num_matches1 = dict_foreach_match (one, match, NULL, key_value_cmp,
+ &cmp);
+
if (num_matches1 == -1)
return _gf_false;