[ovs-dev] [PATCH 14/15] json: Make it safe to pass null pointers to json_equal().

Ben Pfaff blp at ovn.org
Mon Jan 1 05:16:39 UTC 2018


Signed-off-by: Ben Pfaff <blp at ovn.org>
---
 lib/json.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/json.c b/lib/json.c
index 5e93190b8a03..07ca87b2130f 100644
--- a/lib/json.c
+++ b/lib/json.c
@@ -576,9 +576,9 @@ json_equal(const struct json *a, const struct json *b)
 {
     if (a == b) {
         return true;
-    }
-
-    if (a->type != b->type) {
+    } else if (!a || !b) {
+        return false;
+    } else if (a->type != b->type) {
         return false;
     }
 
-- 
2.10.2



More information about the dev mailing list