summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--hash.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/hash.c b/hash.c
index d6092efa..380a4615 100644
--- a/hash.c
+++ b/hash.c
@@ -703,7 +703,10 @@ val hash_next(val iter)
{
struct hash_iter *hi = coerce(struct hash_iter *, cobj_handle(iter, hash_iter_s));
val hash = hi->hash;
- struct hash *h = coerce(struct hash *, hash->co.handle);
+ struct hash *h = hash ? coerce(struct hash *, hash->co.handle) : 0;
+
+ if (!h)
+ return nil;
if (hi->cons)
hi->cons = cdr(hi->cons);
while (nilp(hi->cons)) {