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.
This commit is contained in:
James Prestwood 2022-01-06 14:52:56 -08:00 committed by Denis Kenzior
parent 380896d08a
commit 1f91c03bf6
1 changed files with 2 additions and 1 deletions

View File

@ -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;
}