From d9bfbe363d14f8258d239eb702729926571b88e7 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Mon, 26 Aug 2019 11:14:03 -0700 Subject: Make `gc_update_table_refs` match `mark_tbl_no_pin` a little more closely This commit just makes `gc_update_table_refs` match `mark_tbl_no_pin` more closely. --- gc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'gc.c') diff --git a/gc.c b/gc.c index 0d7732a78e..f7b770b4c3 100644 --- a/gc.c +++ b/gc.c @@ -7770,9 +7770,11 @@ hash_foreach_replace(st_data_t key, st_data_t value, st_data_t argp, int error) } static void -gc_update_table_refs(rb_objspace_t * objspace, st_table *ht) +gc_update_table_refs(rb_objspace_t * objspace, st_table *tbl) { - if (st_foreach_with_replace(ht, hash_foreach_replace, hash_replace_ref, (st_data_t)objspace)) { + if (!tbl || tbl->num_entries == 0) return; + + if (st_foreach_with_replace(tbl, hash_foreach_replace, hash_replace_ref, (st_data_t)objspace)) { rb_raise(rb_eRuntimeError, "hash modified during iteration"); } } -- cgit v1.2.3