Skip to content

Commit c52ed5c

Browse files
committed
Update rehash check to raise if bound increases during iteration
1 parent 243d5ee commit c52ed5c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

hash.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1300,9 +1300,9 @@ 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);
1303+
unsigned bound = RHASH_AR_TABLE_BOUND(arg->hash);
13041304
int status = (*arg->func)((VALUE)key, (VALUE)value, arg->arg);
1305-
if (!RHASH_AR_TABLE_P(arg->hash) || RHASH_AR_TABLE(arg->hash) != tbl) {
1305+
if (!RHASH_AR_TABLE_P(arg->hash) || RHASH_AR_TABLE_BOUND(arg->hash) > bound) {
13061306
rb_raise(rb_eRuntimeError, "rehash occurred during iteration");
13071307
}
13081308

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