fix memory leak when a non-existant exec process is specified
All checks were successful
Generic zig build / build (push) Successful in 21s

This commit is contained in:
Emil Lerch 2025-10-27 14:05:54 -07:00
parent 8a208c237b
commit f188afc25c
Signed by: lobo
GPG key ID: A7B62D657EF764F8

View file

@ -67,9 +67,13 @@ const SpeechHandler = struct {
// SAFETY: this is set 8 lines below before use
.id = undefined,
};
errdefer self.allocator.destroy(process.child.?);
process.child.?.* = std.process.Child.init(&[_][]const u8{ program, text }, self.allocator);
try self.child_processes.append(self.allocator, process);
errdefer _ = self.child_processes.pop();
errdefer {
_ = self.child_processes.pop();
self.child_processes.shrinkAndFree(self.allocator, self.child_processes.items.len);
}
try process.child.?.spawn();
try process.child.?.waitForSpawn();
process.id = process.child.?.id;