Code

utils llist: Fixed a segfault in functions doing lookups.
authorSebastian Harl <sh@tokkee.org>
Wed, 2 Oct 2013 09:06:08 +0000 (11:06 +0200)
committerSebastian Harl <sh@tokkee.org>
Wed, 2 Oct 2013 09:06:08 +0000 (11:06 +0200)
src/utils/llist.c

index 0d61769b26b8daea103c73e6bb3d8d31e1886be3..0af9c8cb11bec4346b96c557275b4a813ccfd618 100644 (file)
@@ -121,8 +121,7 @@ llist_search(sdb_llist_t *list,
 {
        sdb_llist_elem_t *elem;
 
-       if ((! list) || (! lookup))
-               return NULL;
+       assert(list && lookup);
 
        for (elem = list->head; elem; elem = elem->next)
                if (! lookup(elem->obj, user_data))
@@ -311,6 +310,9 @@ sdb_llist_search(sdb_llist_t *list,
 {
        sdb_llist_elem_t *elem;
 
+       if ((! list) || (! lookup))
+               return NULL;
+
        pthread_rwlock_rdlock(&list->lock);
        elem = llist_search(list, lookup, user_data);
        pthread_rwlock_unlock(&list->lock);
@@ -348,6 +350,9 @@ sdb_llist_remove(sdb_llist_t *list,
        sdb_llist_elem_t *elem;
        sdb_object_t *obj = NULL;
 
+       if ((! list) || (! lookup))
+               return NULL;
+
        pthread_rwlock_wrlock(&list->lock);
        elem = llist_search(list, lookup, user_data);
        if (elem)