From 1f91c03bf6de4a3301375fbcf47ff74fe188529d Mon Sep 17 00:00:00 2001 From: James Prestwood Date: Thu, 6 Jan 2022 14:52:56 -0800 Subject: [PATCH] json: add NULL check for container on get_container 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; }