From: Sebastian Harl Date: Wed, 11 Mar 2015 19:01:19 +0000 (+0100) Subject: store_expr: Fix iter_has_next if the first elements are filtered. X-Git-Tag: sysdb-0.8.0~125 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=bf21a7947536605030c9ad409608dd0f3c8fc325;p=sysdb.git store_expr: Fix iter_has_next if the first elements are filtered. --- 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 */