mirror of
https://github.com/ziglang/zig.git
synced 2026-02-14 05:20:34 +00:00
wasm-linker: prevent double-free on parse failure
This commit is contained in:
parent
2672f7d9e8
commit
3fd6e93f4f
@ -353,9 +353,14 @@ fn Parser(comptime ReaderType: type) type {
|
||||
var debug_names = std.ArrayList(u8).init(gpa);
|
||||
|
||||
errdefer {
|
||||
while (relocatable_data.popOrNull()) |rel_data| {
|
||||
gpa.free(rel_data.data[0..rel_data.size]);
|
||||
} else relocatable_data.deinit();
|
||||
// only free the inner contents of relocatable_data if we didn't
|
||||
// assign it to the object yet.
|
||||
if (parser.object.relocatable_data.len == 0) {
|
||||
for (relocatable_data.items) |rel_data| {
|
||||
gpa.free(rel_data.data[0..rel_data.size]);
|
||||
}
|
||||
relocatable_data.deinit();
|
||||
}
|
||||
gpa.free(debug_names.items);
|
||||
debug_names.deinit();
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user