Skip to content

Commit 432e5fa

Browse files
committed
prism_compile.c: Avoid zero length allocation
The constant pool may be empty.
1 parent 135e5bf commit 432e5fa

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

prism_compile.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11053,7 +11053,7 @@ pm_parse_process(pm_parse_result_t *result, pm_node_t *node, VALUE *script_lines
1105311053
// Now set up the constant pool and intern all of the various constants into
1105411054
// their corresponding IDs.
1105511055
scope_node->parser = parser;
11056-
scope_node->constants = xcalloc(parser->constant_pool.size, sizeof(ID));
11056+
scope_node->constants = parser->constant_pool.size ? xcalloc(parser->constant_pool.size, sizeof(ID)) : NULL;
1105711057

1105811058
for (uint32_t index = 0; index < parser->constant_pool.size; index++) {
1105911059
pm_constant_t *constant = &parser->constant_pool.constants[index];

0 commit comments

Comments
 (0)