summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavi Hernandez <xhernandez@redhat.com>2018-04-12 23:31:37 +0200
committerShyamsundar Ranganathan <srangana@redhat.com>2018-04-24 12:50:59 +0000
commit558f5d559ee4b8304f6c91bce1675ce3cda54b14 (patch)
treea6a932860e790361e9c584f3d1a3792fed33d20f
parentb50d7aead1c2a7893dc0f4281bf7fc8027e2dacb (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. Backport of: > BUG: 1566732 BUG: 1569407 Change-Id: I0fc245c2e7d1395865a76405dbd05e5d34db3273 Signed-off-by: Xavi Hernandez <xhernandez@redhat.com>
-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 243c92985a8..6c3fc164d8e 100644
--- a/libglusterfs/src/dict.c
+++ b/libglusterfs/src/dict.c
@@ -188,17 +188,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;