From bf21a7947536605030c9ad409608dd0f3c8fc325 Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Wed, 11 Mar 2015 20:01:19 +0100 Subject: [PATCH] store_expr: Fix iter_has_next if the first elements are filtered. --- src/core/store_expr.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/core/store_expr.c b/src/core/store_expr.c index d9f6e04..8fc063d 100644 --- a/src/core/store_expr.c +++ b/src/core/store_expr.c @@ -385,8 +385,21 @@ sdb_store_expr_iter_has_next(sdb_store_expr_iter_t *iter) if (! iter) return 0; - if (iter->tree) + if (iter->tree) { + /* this function may be called before get_next, + * so we'll have to apply filters here as well */ + if (iter->filter) { + sdb_store_obj_t *child; + while ((child = STORE_OBJ(sdb_avltree_iter_peek_next(iter->tree)))) { + if (sdb_store_matcher_matches(iter->filter, child, NULL)) + break; + (void)sdb_avltree_iter_get_next(iter->tree); + } + } + return sdb_avltree_iter_has_next(iter->tree); + } + return iter->array_idx < iter->array.data.array.length; } /* sdb_store_expr_iter_has_next */ -- 2.30.2