From b8ddfec6c21dffca5a867aeb3bc9d873aeeb4f56 Mon Sep 17 00:00:00 2001 From: Kristian Høgsberg Date: Fri, 20 Jun 2008 20:57:51 -0400 Subject: Fix package queries for empty sets. --- librazor/iterator.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'librazor') diff --git a/librazor/iterator.c b/librazor/iterator.c index 909b954..addbe68 100644 --- a/librazor/iterator.c +++ b/librazor/iterator.c @@ -240,13 +240,15 @@ razor_package_query_finish(struct razor_package_query *pq) struct razor_package_iterator *pi; struct razor_set *set; struct list *index; - int i, j, count; + int i, j; set = pq->set; - count = set->packages.size / sizeof(struct razor_package); - index = zalloc(pq->count * sizeof *index); + if (pq->count > 0) + index = zalloc(pq->count * sizeof *index); + else + index = NULL; - for (i = 0, j = 0; i < count; i++) { + for (i = 0, j = 0; i < pq->count; i++) { if (!pq->vector[i]) continue; @@ -256,6 +258,7 @@ razor_package_query_finish(struct razor_package_query *pq) j++; } + free(pq->vector); free(pq); pi = razor_package_iterator_create_with_index(set, index); -- cgit v1.2.3