From 432e5fa7e4ad57e0d8dcfcec29f0426aac7aedb4 Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Fri, 4 Apr 2025 12:25:03 +0200 Subject: prism_compile.c: Avoid zero length allocation The constant pool may be empty. --- prism_compile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prism_compile.c b/prism_compile.c index 6de3f69c29..a3912c519c 100644 --- a/prism_compile.c +++ b/prism_compile.c @@ -11053,7 +11053,7 @@ pm_parse_process(pm_parse_result_t *result, pm_node_t *node, VALUE *script_lines // Now set up the constant pool and intern all of the various constants into // their corresponding IDs. scope_node->parser = parser; - scope_node->constants = xcalloc(parser->constant_pool.size, sizeof(ID)); + scope_node->constants = parser->constant_pool.size ? xcalloc(parser->constant_pool.size, sizeof(ID)) : NULL; for (uint32_t index = 0; index < parser->constant_pool.size; index++) { pm_constant_t *constant = &parser->constant_pool.constants[index]; -- cgit v1.2.3