From: Sebastian Harl Date: Wed, 2 Oct 2013 09:06:08 +0000 (+0200) Subject: utils llist: Fixed a segfault in functions doing lookups. X-Git-Tag: sysdb-0.1.0~336^2~64 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=2a7356847217432a1858a5686b67f0545102a810;p=sysdb.git utils llist: Fixed a segfault in functions doing lookups. --- diff --git a/src/utils/llist.c b/src/utils/llist.c index 0d61769..0af9c8c 100644 --- a/src/utils/llist.c +++ b/src/utils/llist.c @@ -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)