summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Hawthorn <john@hawthorn.email>2026-04-09 13:22:22 -0700
committerJohn Hawthorn <john@hawthorn.email>2026-04-09 13:55:14 -0700
commit0b5862f4d9f6a1f86b09eadc54cafa106d996a7c (patch)
treed3d85c9be49eb034e2b81f103d0c14b8b4969ec9
parentc91977801797ef15a97aa2f325c7458ef393166b (diff)
Don't use fixed-size hashes for cdhash
This caused out of bounds writes because of converting to a st_table. Co-authored-by: Luke Gruber <luke.gru@gmail.com> Co-authored-by: Matt Valentine-House <matt@eightbitraptor.com>
-rw-r--r--compile.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/compile.c b/compile.c
index e6748d38b3..ac1bdfe0f9 100644
--- a/compile.c
+++ b/compile.c
@@ -12167,7 +12167,7 @@ iseq_build_from_ary_body(rb_iseq_t *iseq, LINK_ANCHOR *const anchor,
case TS_CDHASH:
{
int i;
- VALUE map = rb_hash_alloc_fixed_size(Qfalse, RARRAY_LEN(op)/2);
+ VALUE map = rb_hash_new_with_size(RARRAY_LEN(op)/2);
RHASH_TBL_RAW(map)->type = &cdhash_type;
op = rb_to_array_type(op);
@@ -12179,7 +12179,7 @@ iseq_build_from_ary_body(rb_iseq_t *iseq, LINK_ANCHOR *const anchor,
rb_hash_aset(map, key, (VALUE)label | 1);
}
RB_GC_GUARD(op);
- RB_OBJ_SET_SHAREABLE(map); // allow mutation while compiling
+ RB_OBJ_SET_SHAREABLE(rb_obj_hide(map)); // allow mutation while compiling
argv[j] = map;
RB_OBJ_WRITTEN(iseq, Qundef, map);
}