Skip to content

Commit

Permalink
[PRISM] Fix flaky memory in scope nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
kddnewton committed Feb 9, 2024
1 parent 8688256 commit e96c838
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
13 changes: 5 additions & 8 deletions prism_compile.c
Expand Up @@ -2439,24 +2439,21 @@ pm_compile_pattern(rb_iseq_t *iseq, pm_scope_node_t *scope_node, const pm_node_t
void
pm_scope_node_init(const pm_node_t *node, pm_scope_node_t *scope, pm_scope_node_t *previous, const pm_parser_t *parser)
{
// This is very important, otherwise the scope node could be seen as having
// certain flags set that _should not_ be set.
memset(scope, 0, sizeof(pm_scope_node_t));

scope->base.type = PM_SCOPE_NODE;
scope->base.location.start = node->location.start;
scope->base.location.end = node->location.end;

scope->previous = previous;
scope->parser = parser;
scope->ast_node = (pm_node_t *)node;
scope->parameters = NULL;
scope->body = NULL;
scope->constants = NULL;
scope->local_table_for_iseq_size = 0;

if (previous) {
scope->constants = previous->constants;
}
scope->index_lookup_table = NULL;

pm_constant_id_list_init(&scope->locals);

switch (PM_NODE_TYPE(node)) {
case PM_BLOCK_NODE: {
Expand Down Expand Up @@ -2541,7 +2538,7 @@ pm_scope_node_init(const pm_node_t *node, pm_scope_node_t *scope, pm_scope_node_
default:
assert(false && "unreachable");
break;
}
}
}

void
Expand Down
3 changes: 0 additions & 3 deletions test/.excludes-prism/TestSetTraceFunc.rb

This file was deleted.

0 comments on commit e96c838

Please sign in to comment.