Skip to content

Commit 9371042

Browse files
Guard rb_obj_embedded_size for zero fields
With smaller pool sizes (e.g. 32 bytes), an RObject with 0 embedded fields would request a size smaller than the minimum meaningful object. Ensure at least 1 field worth of space so the embedded size is always large enough for a valid RObject.
1 parent 772bde3 commit 9371042

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

internal/object.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ RBASIC_SET_CLASS(VALUE obj, VALUE klass)
6464
static inline size_t
6565
rb_obj_embedded_size(uint32_t fields_count)
6666
{
67+
if (fields_count < 1) fields_count = 1;
6768
return offsetof(struct RObject, as.ary) + (sizeof(VALUE) * fields_count);
6869
}
6970
#endif /* INTERNAL_OBJECT_H */

0 commit comments

Comments
 (0)