Code

store: When advancing an iterator don't loop endlessly on filtered objects.
authorSebastian Harl <sh@tokkee.org>
Sun, 8 Mar 2015 21:56:09 +0000 (22:56 +0100)
committerSebastian Harl <sh@tokkee.org>
Sun, 8 Mar 2015 21:56:09 +0000 (22:56 +0100)
src/core/store_expr.c

index ddaeccd1f5f0dac21f196e2879d17b226b351dea..d9f6e0462b65c39e5e67c4b787139507c3969e43 100644 (file)
@@ -417,10 +417,13 @@ sdb_store_expr_iter_get_next(sdb_store_expr_iter_t *iter)
                }
 
                /* Skip over any filtered objects */
-               if (iter->filter)
-                       while ((child = STORE_OBJ(sdb_avltree_iter_peek_next(iter->tree))))
+               if (iter->filter) {
+                       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 ret;
        }