From d9b3c528e99a5c9307470eb08f807eb3d0791cc4 Mon Sep 17 00:00:00 2001 From: Rene Schallner Date: Sun, 23 Apr 2023 00:28:46 +0200 Subject: [PATCH] fixed pkghash --- tools/pkghash.zig | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/pkghash.zig b/tools/pkghash.zig index 846850e..6d30f7b 100644 --- a/tools/pkghash.zig +++ b/tools/pkghash.zig @@ -196,7 +196,11 @@ pub fn cmdPkgGit(gpa: Allocator, args: []const []const u8) !void { } } - defer gpa.free(git_tag.?); + errdefer { + if (git_tag) |g| { + gpa.free(g); + } + } const hash = blk: { const result = try gitFileList(gpa, cwd_absolute_path); @@ -222,6 +226,9 @@ pub fn cmdPkgGit(gpa: Allocator, args: []const []const u8) !void { } else { try renderTemplate(gpa, git_tag.?, template_filn.?, digest_slice); } + if (git_tag) |g| { + gpa.free(g); + } } fn renderTemplate(gpa: std.mem.Allocator, tag: []const u8, template: []const u8, hash: []const u8) !void {