diff --git a/spa/include/spa/utils/json.h b/spa/include/spa/utils/json.h index 9e612b687..c1c324e03 100644 --- a/spa/include/spa/utils/json.h +++ b/spa/include/spa/utils/json.h @@ -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) diff --git a/src/tests/test-properties.c b/src/tests/test-properties.c index 6fc52c248..2ad026166 100644 --- a/src/tests/test-properties.c +++ b/src/tests/test-properties.c @@ -222,6 +222,16 @@ static void test_new_string(void) spa_assert(!strcmp(pw_properties_get(props, "empty"), "")); pw_properties_free(props); + + props = pw_properties_new_string("foo=bar bar=baz"); + spa_assert(props != NULL); + spa_assert(props->flags == 0); + spa_assert(props->dict.n_items == 2); + + spa_assert(!strcmp(pw_properties_get(props, "foo"), "bar")); + spa_assert(!strcmp(pw_properties_get(props, "bar"), "baz")); + + pw_properties_free(props); } static void test_update(void)