json: set state on final bare string

When we run out of chars and are inside a bare string, set our state
so that the next round will continue instead of looping forever.
This commit is contained in:
Wim Taymans 2020-12-31 17:07:03 +01:00
parent 49d11acde0
commit 799bc13c85
2 changed files with 17 additions and 5 deletions

View file

@ -164,11 +164,13 @@ static inline int spa_json_next(struct spa_json * iter, const char **value)
}
}
return (iter->depth == 0 ?
(iter->state == __BARE && iter->cur < iter->end ?
iter->cur - *value :
0) :
-1);
if (iter->depth != 0)
return -1;
if (iter->state == __BARE) {
iter->state = __STRUCT;
return iter->cur - *value;
}
return 0;
}
static inline int spa_json_enter_container(struct spa_json *iter, struct spa_json *sub, char type)