hashtbl: make hash_iterate() not crash on an uninitalized table

Trying to walk an uninitialized table (->table == NULL) should just
return nothing.  This can happen due when pp_cleanup() is called after
a failure.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
This commit is contained in:
H. Peter Anvin 2009-06-27 15:54:25 -07:00
parent f7a9ecaffa
commit eac7892834

View File

@ -156,8 +156,11 @@ void *hash_iterate(const struct hash_table *head,
struct hash_tbl_node *np = *iterator;
struct hash_tbl_node *ep = head->table + head->size;
if (!np)
if (!np) {
np = head->table;
if (!np)
return NULL; /* Uninitialized table */
}
while (np < ep) {
if (np->key) {