Wireless Daemon for Linux
 help / color / mirror / Atom feed
* [PATCH v2 3/5] json: add NULL check for container on get_container
@ 2022-01-06 22:52 James Prestwood
  0 siblings, 0 replies; only message in thread
From: James Prestwood @ 2022-01-06 22:52 UTC (permalink / raw)
  To: iwd 

[-- Attachment #1: Type: text/plain, Size: 559 bytes --]

In case the caller just wants to check an object is iterable,
without actually iterating it.
---
 src/json.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/json.c b/src/json.c
index b89fbaa6..0942dae3 100644
--- a/src/json.c
+++ b/src/json.c
@@ -393,7 +393,8 @@ bool json_iter_get_container(struct json_iter *iter,
 	if (t->type != JSMN_OBJECT && t->type != JSMN_ARRAY)
 		return false;
 
-	iter_recurse(iter, t, container);
+	if (container)
+		iter_recurse(iter, t, container);
 
 	return true;
 }
-- 
2.31.1

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2022-01-06 22:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-06 22:52 [PATCH v2 3/5] json: add NULL check for container on get_container James Prestwood

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox