mirror of
https://github.com/netwide-assembler/nasm.git
synced 2024-11-21 03:14:19 +08:00
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:
parent
f7a9ecaffa
commit
eac7892834
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user