diff --git a/src/json.c b/src/json.c index 0942dae3..69c1dcdb 100644 --- a/src/json.c +++ b/src/json.c @@ -200,6 +200,9 @@ bool json_iter_parse(struct json_iter *iter, enum json_type type, ...) if (iter->start == -1) return false; + if (c->tokens[iter->start].type != JSMN_OBJECT) + return false; + args = l_queue_new(); va_start(va, type); @@ -427,6 +430,9 @@ bool json_iter_next(struct json_iter *iter) jsmntok_t *t = c->tokens + iter->current; int inc = 1; + if (c->tokens[iter->start].type != JSMN_ARRAY) + return false; + /* * If this is the initial iteration skip this and just increment * current by 1 since this iterator points to a container which needs to