commit:     83eaa405a97e45e8cdbf20ad1bb30e82c902d7e2
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon Dec 13 07:22:30 2021 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon Dec 13 07:22:30 2021 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=83eaa405

libq/set: allow array_set to be used with an empty set

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 libq/set.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/libq/set.c b/libq/set.c
index 88b5876..6c9fae0 100644
--- a/libq/set.c
+++ b/libq/set.c
@@ -271,6 +271,11 @@ array_set(set *q, array_t *ret)
        array_t blank = array_init_decl;
 
        *ret = blank;
+
+       /* allow using empty set */
+       if (q == NULL)
+               return 0;
+
        for (i = 0; i < _SET_HASH_SIZE; i++) {
                for (w = q->buckets[i]; w != NULL; w = w->next)
                        xarraypush_ptr(ret, w->name);

Reply via email to