commit fd7a97b3b2607c6de49e96ed32a7be0a037c67a8 (tree)
parent e42b7702eb2c74b923aa88492886c3f316188e99
Author: Andrew Kelley <andrew@ziglang.org>
Date: Wed, 24 Jun 2020 16:20:02 -0400
fix memory leak of anonymous decl name
Diffstat:
1 file changed, 1 insertion(+), 0 deletions(-)
diff --git a/src-self-hosted/Module.zig b/src-self-hosted/Module.zig
@@ -2378,6 +2378,7 @@ fn createAnonymousDecl(
const name_index = self.getNextAnonNameIndex();
const scope_decl = scope.decl().?;
const name = try std.fmt.allocPrint(self.allocator, "{}${}", .{ scope_decl.name, name_index });
+ defer self.allocator.free(name);
const name_hash = scope.namespace().fullyQualifiedNameHash(name);
const src_hash: std.zig.SrcHash = undefined;
const new_decl = try self.createNewDecl(scope, name, scope_decl.src_index, name_hash, src_hash);