summaryrefslogtreecommitdiff
path: root/array.c
diff options
context:
space:
mode:
authorPeter Zhu <peter@peterzhu.ca>2025-11-01 10:51:04 -0400
committerPeter Zhu <peter@peterzhu.ca>2025-11-02 09:17:17 -0500
commit2380f69f6875709ee4c37095cea4e6163d9faac1 (patch)
tree2330460d925fb4b12a55153429aef6b129f6099f /array.c
parentdba4c9fbe79bdc3b7679330760d2b27d29a9911a (diff)
Fix array allocation when slot size < 40 bytes
We need to allocate at least sizeof(struct RArray) when the array is embedded on garbage collectors that support slot sizes less than 40 bytes.
Diffstat (limited to 'array.c')
-rw-r--r--array.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/array.c b/array.c
index 12f45e2cbb..b71123532d 100644
--- a/array.c
+++ b/array.c
@@ -194,7 +194,9 @@ ary_embed_capa(VALUE ary)
static size_t
ary_embed_size(long capa)
{
- return offsetof(struct RArray, as.ary) + (sizeof(VALUE) * capa);
+ size_t size = offsetof(struct RArray, as.ary) + (sizeof(VALUE) * capa);
+ if (size < sizeof(struct RArray)) size = sizeof(struct RArray);
+ return size;
}
static bool