gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnunet] branch master updated: fix #6525: handle explicit null in JSON


From: gnunet
Subject: [gnunet] branch master updated: fix #6525: handle explicit null in JSON nicely
Date: Sun, 25 Oct 2020 21:40:06 +0100

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository gnunet.

The following commit(s) were added to refs/heads/master by this push:
     new d8cf5cbfc fix #6525: handle explicit null in JSON nicely
d8cf5cbfc is described below

commit d8cf5cbfc9862d9187d9b15d12f7be523b757791
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sun Oct 25 21:32:57 2020 +0100

    fix #6525: handle explicit null in JSON nicely
---
 src/include/gnunet_json_lib.h |  2 +-
 src/json/json.c               | 14 ++++++++++----
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/src/include/gnunet_json_lib.h b/src/include/gnunet_json_lib.h
index 92597d3dd..3dc79105e 100644
--- a/src/include/gnunet_json_lib.h
+++ b/src/include/gnunet_json_lib.h
@@ -1,6 +1,6 @@
 /*
    This file is part of GNUnet
-   Copyright (C) 2014, 2015, 2016 GNUnet e.V.
+   Copyright (C) 2014, 2015, 2016, 2020 GNUnet e.V.
 
    GNUnet is free software: you can redistribute it and/or modify it
    under the terms of the GNU Affero General Public License as published
diff --git a/src/json/json.c b/src/json/json.c
index 0631c51bb..503702962 100644
--- a/src/json/json.c
+++ b/src/json/json.c
@@ -56,11 +56,17 @@ GNUNET_JSON_parse (const json_t *root,
     if (NULL == spec[i].field)
       pos = (json_t *) root;
     else
-      pos = json_object_get (root, spec[i].field);
-    if ((NULL == pos) && (spec[i].is_optional))
+      pos = json_object_get (root,
+                             spec[i].field);
+    if ( ( (NULL == pos) ||
+           (json_is_null (pos) ) ) &&
+         (spec[i].is_optional) )
       continue;
-    if ((NULL == pos) ||
-        (GNUNET_OK != spec[i].parser (spec[i].cls, pos, &spec[i])))
+    if ( (NULL == pos) ||
+         (GNUNET_OK !=
+          spec[i].parser (spec[i].cls,
+                          pos,
+                          &spec[i])) )
     {
       if (NULL != error_json_name)
         *error_json_name = spec[i].field;

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]