diff options
author | Jean Boussier <[email protected]> | 2025-04-04 12:25:03 +0200 |
---|---|---|
committer | Jean Boussier <[email protected]> | 2025-04-07 12:00:09 +0200 |
commit | 432e5fa7e4ad57e0d8dcfcec29f0426aac7aedb4 (patch) | |
tree | 0db23860849f7cd2ffe361bfae2c5b8c9dc348eb /prism_compile.c | |
parent | 135e5bff9ad51fc1a1322609f4ca0c1df7c9286a (diff) |
prism_compile.c: Avoid zero length allocation
The constant pool may be empty.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/13068
Diffstat (limited to 'prism_compile.c')
-rw-r--r-- | prism_compile.c | 2 |
1 files changed, 1 insertions, 1 deletions
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]; |