Skip to content

Commit 0b5862f

Browse files
jhawthornluke-grueightbitraptor
committed
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>
1 parent c919778 commit 0b5862f

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

compile.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12167,7 +12167,7 @@ iseq_build_from_ary_body(rb_iseq_t *iseq, LINK_ANCHOR *const anchor,
1216712167
case TS_CDHASH:
1216812168
{
1216912169
int i;
12170-
VALUE map = rb_hash_alloc_fixed_size(Qfalse, RARRAY_LEN(op)/2);
12170+
VALUE map = rb_hash_new_with_size(RARRAY_LEN(op)/2);
1217112171

1217212172
RHASH_TBL_RAW(map)->type = &cdhash_type;
1217312173
op = rb_to_array_type(op);
@@ -12179,7 +12179,7 @@ iseq_build_from_ary_body(rb_iseq_t *iseq, LINK_ANCHOR *const anchor,
1217912179
rb_hash_aset(map, key, (VALUE)label | 1);
1218012180
}
1218112181
RB_GC_GUARD(op);
12182-
RB_OBJ_SET_SHAREABLE(map); // allow mutation while compiling
12182+
RB_OBJ_SET_SHAREABLE(rb_obj_hide(map)); // allow mutation while compiling
1218312183
argv[j] = map;
1218412184
RB_OBJ_WRITTEN(iseq, Qundef, map);
1218512185
}

0 commit comments

Comments
 (0)