summaryrefslogtreecommitdiff
path: root/gc.c
diff options
context:
space:
mode:
authorAaron Patterson <tenderlove@ruby-lang.org>2019-08-26 11:14:03 -0700
committerAaron Patterson <tenderlove@ruby-lang.org>2019-08-26 11:14:03 -0700
commitd9bfbe363d14f8258d239eb702729926571b88e7 (patch)
treeb6f8182bcab36aaf42e5903054f6a43c92615788 /gc.c
parent3a4a58e2ccf13be874cc81e9c663bd39e687acd3 (diff)
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.
Diffstat (limited to 'gc.c')
-rw-r--r--gc.c6
1 files changed, 4 insertions, 2 deletions
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");
}
}