mirror of
https://github.com/ruby/ruby.git
synced 2026-10-28 16:36:20 +08:00
Prevent overflow of length bits for embedded arrays
Embedded arrays only use 7 bits for the length, so it will overflow if the GC can allocate large slots. We need to add the cap to ary_embeddable_p.
This commit is contained in:
1 parent
9eb455cdd1
commit
79da507032
1 file changed
+3
-1
Notes:
git
2026-07-10 06:36:22 +00:00
@@ -208,7 +208,9 @@ ary_embed_size(long capa)
|
||||
static bool
|
||||
ary_embeddable_p(long capa)
|
||||
{
|
||||
return rb_gc_size_allocatable_p(ary_embed_size(capa));
|
||||
const long embed_len_max = RARRAY_EMBED_LEN_MASK >> RARRAY_EMBED_LEN_SHIFT;
|
||||
|
||||
return capa <= embed_len_max && rb_gc_size_allocatable_p(ary_embed_size(capa));
|
||||
}
|
||||
|
||||
bool
|
||||
|
||||
Reference in new issue
Block a user