summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-10-25 21:32:57 +0100
committerChristian Grothoff <christian@grothoff.org>2020-10-25 21:32:57 +0100
commitd8cf5cbfc9862d9187d9b15d12f7be523b757791 (patch)
tree07313275d4be3e1ebf37f8b8c91e3f2ce2af3132 /src
parentbea59c001049c035ce29ff6bb6680c0d6bc86283 (diff)
fix #6525: handle explicit null in JSON nicely
Diffstat (limited to 'src')
-rw-r--r--src/include/gnunet_json_lib.h2
-rw-r--r--src/json/json.c14
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;