Skip to content

Commit 01243b5

Browse files
authored
Close expr_array is_typecheck_error early return leak (#5217)
When is_typecheck_error(c_type) fires after the accumulator loop has run at least one iteration, `type` may be a freshly-allocated orphan tree from a prior type_union call. The adjacent AST_FLAG_JUMPS_AWAY exit correctly calls ast_free_unattached(type) before returning, but this path did not. Closes #5212
1 parent b35563f commit 01243b5

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/libponyc/expr/array.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,10 @@ bool expr_array(pass_opt_t* opt, ast_t** astp)
476476

477477
ast_t* c_type = ast_type(ele);
478478
if(is_typecheck_error(c_type))
479+
{
480+
ast_free_unattached(type);
479481
return false;
482+
}
480483

481484
if(told_type)
482485
{

0 commit comments

Comments
 (0)