authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-05-15 18:54:48-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-05-15 18:54:48-04:00
log8980f150e94f5542f5228e371fd2919a9922dc12
tree0fdc3904e59173799d10e69c54d57bc05e7aee73
parente1d4b59c5bd47c7bef3e41279c97cd36991676e2

fix memory leaks of one of the ZIR test cases


1 files changed, 11 insertions(+), 2 deletions(-)

src-self-hosted/ir.zig+11-2
...@@ -487,11 +487,13 @@ pub const Module = struct {...@@ -487,11 +487,13 @@ pub const Module = struct {
487 .loaded_success => {487 .loaded_success => {
488 allocator.free(self.source.bytes);488 allocator.free(self.source.bytes);
489 self.contents.module.deinit(allocator);489 self.contents.module.deinit(allocator);
490 allocator.destroy(self.contents.module);
490 self.status = .unloaded_success;491 self.status = .unloaded_success;
491 },492 },
492 .loaded_sema_failure => {493 .loaded_sema_failure => {
493 allocator.free(self.source.bytes);494 allocator.free(self.source.bytes);
494 self.contents.module.deinit(allocator);495 self.contents.module.deinit(allocator);
496 allocator.destroy(self.contents.module);
495 self.status = .unloaded_sema_failure;497 self.status = .unloaded_sema_failure;
496 },498 },
497 .loaded_parse_failure => {499 .loaded_parse_failure => {
...@@ -603,7 +605,14 @@ pub const Module = struct {...@@ -603,7 +605,14 @@ pub const Module = struct {
603 }605 }
604 self.failed_exports.deinit();606 self.failed_exports.deinit();
605 }607 }
606 self.decl_exports.deinit();608 {
609 var it = self.decl_exports.iterator();
610 while (it.next()) |kv| {
611 const export_list = kv.value;
612 allocator.free(export_list);
613 }
614 self.decl_exports.deinit();
615 }
607 {616 {
608 var it = self.export_owners.iterator();617 var it = self.export_owners.iterator();
609 while (it.next()) |kv| {618 while (it.next()) |kv| {
...@@ -613,7 +622,7 @@ pub const Module = struct {...@@ -613,7 +622,7 @@ pub const Module = struct {
613 }622 }
614 allocator.free(export_list);623 allocator.free(export_list);
615 }624 }
616 self.failed_exports.deinit();625 self.export_owners.deinit();
617 }626 }
618 self.root_pkg.destroy();627 self.root_pkg.destroy();
619 {628 {