summaryrefslogtreecommitdiff
path: root/hashtbl.c
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2009-06-27 15:54:25 -0700
committerH. Peter Anvin <hpa@zytor.com>2009-06-27 15:54:25 -0700
commiteac7892834d5060030133a22edae6b3ee68c76d8 (patch)
treed7d0e0055bd84de191ab9d5cad3b6227da001c20 /hashtbl.c
parentf7a9ecaffad2b8dea7171ebac16fe9703d1b58e1 (diff)
downloadnasm-eac7892834d5060030133a22edae6b3ee68c76d8.tar.gz
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>
Diffstat (limited to 'hashtbl.c')
-rw-r--r--hashtbl.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/hashtbl.c b/hashtbl.c
index a733f455..99af8b8c 100644
--- a/hashtbl.c
+++ b/hashtbl.c
@@ -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) {