Skip to content

Commit 243d5ee

Browse files
committed
Detect rehash in array-backed hashes
1 parent 15cf72d commit 243d5ee

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

hash.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1300,8 +1300,11 @@ hash_ar_foreach_iter(st_data_t key, st_data_t value, st_data_t argp, int error)
13001300

13011301
if (error) return ST_STOP;
13021302

1303+
ar_table *tbl = RHASH_AR_TABLE(arg->hash);
13031304
int status = (*arg->func)((VALUE)key, (VALUE)value, arg->arg);
1304-
/* TODO: rehash check? rb_raise(rb_eRuntimeError, "rehash occurred during iteration"); */
1305+
if (!RHASH_AR_TABLE_P(arg->hash) || RHASH_AR_TABLE(arg->hash) != tbl) {
1306+
rb_raise(rb_eRuntimeError, "rehash occurred during iteration");
1307+
}
13051308

13061309
return hash_iter_status_check(status);
13071310
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy