fix some memory leaks

This commit is contained in:
Luna 2020-08-18 17:58:04 -03:00
parent 353d8d6947
commit 4adf80e51a
1 changed files with 5 additions and 0 deletions

View File

@ -40,6 +40,8 @@ pub const Runner = struct {
if (self.image) |image| {
image.close();
}
std.process.argsFree(self.allocator, self.args);
}
pub fn clone(self: *Runner) !Runner {
@ -117,6 +119,7 @@ pub const Runner = struct {
}
}
/// Caller owns returned memory.
fn makeGlitchedPath(self: *Runner) ![]const u8 {
// we want to transform basename, if it is "x.bmp" to "x_gN.bmp", where
// N is the maximum non-used integer.
@ -180,6 +183,7 @@ pub const Runner = struct {
fn quicksaveCmd(self: *Runner) !void {
var image = try self.getImage();
const out_path = try self.makeGlitchedPath();
defer self.allocator.free(out_path);
try image.saveTo(out_path);
}
@ -187,6 +191,7 @@ pub const Runner = struct {
const runqs = cmd.cast(lang.Command.RunQS).?;
var image = try self.getImage();
const out_path = try self.makeGlitchedPath();
defer self.allocator.free(out_path);
try image.saveTo(out_path);
var proc = try std.ChildProcess.init(