diff options
author | Kristian Høgsberg <krh@redhat.com> | 2008-06-20 20:57:51 -0400 |
---|---|---|
committer | Kristian Høgsberg <krh@redhat.com> | 2008-06-20 20:57:51 -0400 |
commit | b8ddfec6c21dffca5a867aeb3bc9d873aeeb4f56 (patch) | |
tree | 1caed7a0276810e5328c96c09c89de3f8ebb6de8 | |
parent | 18edc4ab189b56e1d56db201f6cc73d4b5f58222 (diff) |
Fix package queries for empty sets.
-rw-r--r-- | librazor/iterator.c | 11 |
1 files changed, 7 insertions, 4 deletions
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); |