mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
prism_compile.c: Avoid zero length allocation
The constant pool may be empty.
This commit is contained in:
parent
135e5bff9a
commit
432e5fa7e4
Notes:
git
2025-04-07 10:00:27 +00:00
1 changed files with 1 additions and 1 deletions
|
@ -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];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue