a3470f
From a3cfdb4e3f32336f2fd16ac68bc4dc5a33e7f26e Mon Sep 17 00:00:00 2001
a3470f
From: Xavi Hernandez <xhernandez@redhat.com>
a3470f
Date: Thu, 12 Apr 2018 23:31:37 +0200
a3470f
Subject: [PATCH 233/236] libglusterfs: fix comparison of a NULL dict with a
a3470f
 non-NULL dict
a3470f
a3470f
Function are_dicts_equal() had a bug when the first argument was NULL and
a3470f
the second one wasn't NULL. In this case it incorrectly returned that the
a3470f
dicts were different when they could be equal.
a3470f
a3470f
Upstream-patch: https://review.gluster.org/19861
a3470f
BUG: 1569457
a3470f
Change-Id: I0fc245c2e7d1395865a76405dbd05e5d34db3273
a3470f
Signed-off-by: Xavi Hernandez <xhernandez@redhat.com>
a3470f
Reviewed-on: https://code.engineering.redhat.com/gerrit/136332
a3470f
Tested-by: RHGS Build Bot <nigelb@redhat.com>
a3470f
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
a3470f
---
a3470f
 libglusterfs/src/dict.c | 16 ++++++++--------
a3470f
 1 file changed, 8 insertions(+), 8 deletions(-)
a3470f
a3470f
diff --git a/libglusterfs/src/dict.c b/libglusterfs/src/dict.c
a3470f
index ebcf694..36d91a7 100644
a3470f
--- a/libglusterfs/src/dict.c
a3470f
+++ b/libglusterfs/src/dict.c
a3470f
@@ -188,17 +188,17 @@ are_dicts_equal (dict_t *one, dict_t *two,
a3470f
         if (!match)
a3470f
                 match = dict_match_everything;
a3470f
 
a3470f
-        cmp.dict = two;
a3470f
-        cmp.value_ignore = value_ignore;
a3470f
-        if (!two) {
a3470f
-                num_matches1 = dict_foreach_match (one, match, NULL,
a3470f
-                                                   dict_null_foreach_fn, NULL);
a3470f
+        if ((one == NULL) || (two == NULL)) {
a3470f
+                num_matches1 = dict_foreach_match(one ? one : two, match, NULL,
a3470f
+                                                  dict_null_foreach_fn, NULL);
a3470f
                 goto done;
a3470f
-        } else {
a3470f
-                num_matches1 = dict_foreach_match (one, match, NULL,
a3470f
-                                                   key_value_cmp, &cmp);
a3470f
         }
a3470f
 
a3470f
+        cmp.dict = two;
a3470f
+        cmp.value_ignore = value_ignore;
a3470f
+        num_matches1 = dict_foreach_match (one, match, NULL, key_value_cmp,
a3470f
+                                           &cmp);
a3470f
+
a3470f
         if (num_matches1 == -1)
a3470f
                 return _gf_false;
a3470f
 
a3470f
-- 
a3470f
1.8.3.1
a3470f