summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Zhu <peter@peterzhu.ca>2026-01-01 16:36:17 -0500
committerPeter Zhu <peter@peterzhu.ca>2026-01-02 08:54:56 -0500
commitb9819ad06c883e6ea4f9e903c5bab06f175efb62 (patch)
treeb6df60e42238da5b493545775edbaa9d54f0520c
parent177949c8b28587a0e0c0709d726cef846bdc51aa (diff)
Register a dupped identity hash as pinning
-rw-r--r--hash.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/hash.c b/hash.c
index c4e8512f64..b0de8e9433 100644
--- a/hash.c
+++ b/hash.c
@@ -1497,6 +1497,10 @@ rb_hash_new_capa(long capa)
static VALUE
hash_copy(VALUE ret, VALUE hash)
{
+ if (rb_hash_compare_by_id_p(hash)) {
+ rb_gc_register_pinning_obj(ret);
+ }
+
if (RHASH_AR_TABLE_P(hash)) {
if (RHASH_AR_TABLE_P(ret)) {
ar_copy(ret, hash);