From 4aa74b605c9960192c30c711fa6e982727eb8d1b Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Thu, 3 Apr 2025 16:07:34 +0200 Subject: [PATCH] compile.c: avoid allocating 0 length call_data if `body->ci_size` is `0`, there's no point allocating 0B, it just wastes an entry in the allocator. --- compile.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/compile.c b/compile.c index cd7e92298c..e97c61eb10 100644 --- a/compile.c +++ b/compile.c @@ -2596,7 +2596,13 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *const anchor) else { body->is_entries = NULL; } - body->call_data = ZALLOC_N(struct rb_call_data, body->ci_size); + + if (body->ci_size) { + body->call_data = ZALLOC_N(struct rb_call_data, body->ci_size); + } + else { + body->call_data = NULL; + } ISEQ_COMPILE_DATA(iseq)->ci_index = 0; // Calculate the bitmask buffer size. @@ -13370,6 +13376,11 @@ ibf_load_ci_entries(const struct ibf_load *load, unsigned int ci_size, struct rb_call_data **cd_ptr) { + if (!ci_size) { + *cd_ptr = NULL; + return; + } + ibf_offset_t reading_pos = ci_entries_offset; unsigned int i;