diff options
author | James Bowes <jbowes@redhat.com> | 2008-06-23 21:20:16 -0400 |
---|---|---|
committer | James Bowes <jbowes@redhat.com> | 2008-06-23 21:20:16 -0400 |
commit | fd60e3a9808554f753e0466b36977aba98841656 (patch) | |
tree | d154827d475f5021a64824cc095ac381968b7b8a /librazor | |
parent | 24e8398fb80019f488396776df3b22f53c47c7a1 (diff) |
Create an empty package iterator when we don't know about the given file.
This is an easy way to stop segfaults when trying to destroy iterators for
unknown files.
Diffstat (limited to 'librazor')
-rw-r--r-- | librazor/iterator.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/librazor/iterator.c b/librazor/iterator.c index e684d7b..1169630 100644 --- a/librazor/iterator.c +++ b/librazor/iterator.c @@ -36,6 +36,13 @@ razor_package_iterator_create_with_index(struct razor_set *set, return pi; } +static struct razor_package_iterator * +razor_package_iterator_create_empty(struct razor_set *set) +{ + struct razor_package_iterator *pi; + return zalloc(sizeof *pi); +} + RAZOR_EXPORT struct razor_package_iterator * razor_package_iterator_create(struct razor_set *set) { @@ -78,7 +85,7 @@ razor_package_iterator_create_for_file(struct razor_set *set, entry = razor_set_find_entry(set, set->files.data, filename); if (entry == NULL) - return NULL; + return razor_package_iterator_create_empty(set); index = list_first(&entry->packages, &set->package_pool); return razor_package_iterator_create_with_index(set, index); |