authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2023-05-18 01:14:11 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2023-05-18 01:14:11 -07:00
log02b234d0a75d4c93ddcbe62d010e4445c0e94fc9
tree2398a4562e13a75c0ee9028b2c38528d99add51b
parenta9d3588173ab80ce564b8aeba4113384d18c2411

fix invalid free of version() result


1 files changed, 3 insertions(+), 1 deletions(-)

git.zig+3-1
......@@ -16,8 +16,10 @@ pub fn version(alloc: std.mem.Allocator) !string {
1616 .argv = &.{ "git", "--version" },
1717 .max_output_bytes = 1024,
1818 });
19 defer alloc.free(result.stdout);
20 defer alloc.free(result.stderr);
1921 std.debug.assert(result.term == .Exited and result.term.Exited == 0);
20 return extras.trimPrefixEnsure(std.mem.trimRight(u8, result.stdout, "\n"), "git version ").?;
22 return try alloc.dupe(u8, extras.trimPrefixEnsure(std.mem.trimRight(u8, result.stdout, "\n"), "git version ").?);
2123}
2224
2325/// Returns the result of running `git rev-parse HEAD`