summaryrefslogtreecommitdiff
path: root/hash.c
diff options
context:
space:
mode:
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/hash.c b/hash.c
index 209fe26c37..89666ca831 100644
--- a/hash.c
+++ b/hash.c
@@ -131,9 +131,13 @@ rb_hash_foreach_iter(key, value, arg)
if (key == Qundef) return ST_CONTINUE;
status = (*arg->func)(key, value, arg->arg);
- if (RHASH(arg->hash)->tbl != tbl || RHASH(arg->hash)->tbl->bins != bins){
+ if (RHASH(arg->hash)->tbl != tbl ||
+ RHASH(arg->hash)->tbl->bins != bins) {
rb_raise(rb_eIndexError, "rehash occurred during iteration");
}
+ if (RHASH(arg->hash)->iter_lev == 0) {
+ rb_raise(rb_eArgError, "block re-entered");
+ }
return status;
}