mirror of
https://github.com/ziglang/zig.git
synced 2026-02-14 13:30:45 +00:00
std.zig.Ast: Fix error case memory leak in parse()
This commit is contained in:
parent
89db4f2e93
commit
525466b49d
@ -181,14 +181,19 @@ pub fn parse(gpa: Allocator, source: [:0]const u8, mode: Mode) Allocator.Error!A
|
||||
.zon => try parser.parseZon(),
|
||||
}
|
||||
|
||||
const extra_data = try parser.extra_data.toOwnedSlice(gpa);
|
||||
errdefer gpa.free(extra_data);
|
||||
const errors = try parser.errors.toOwnedSlice(gpa);
|
||||
errdefer gpa.free(errors);
|
||||
|
||||
// TODO experiment with compacting the MultiArrayList slices here
|
||||
return Ast{
|
||||
.source = source,
|
||||
.mode = mode,
|
||||
.tokens = tokens.toOwnedSlice(),
|
||||
.nodes = parser.nodes.toOwnedSlice(),
|
||||
.extra_data = try parser.extra_data.toOwnedSlice(gpa),
|
||||
.errors = try parser.errors.toOwnedSlice(gpa),
|
||||
.extra_data = extra_data,
|
||||
.errors = errors,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user