From d2456e86f56b7220d0d3deb072bed247fa59cede Mon Sep 17 00:00:00 2001 From: Jan200101 Date: Wed, 4 Mar 2026 20:05:44 +0100 Subject: [PATCH] fix: properly cleanup on error during init --- falcond/src/daemon.zig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/falcond/src/daemon.zig b/falcond/src/daemon.zig index fff9885..972f75c 100644 --- a/falcond/src/daemon.zig +++ b/falcond/src/daemon.zig @@ -35,6 +35,7 @@ pub const Daemon = struct { errdefer config.deinit(); const power_profiles = try PowerProfiles.init(allocator, config); + errdefer if (power_profiles) |pp| pp.deinit(); var performance_mode = false; if (power_profiles) |pp| { @@ -45,12 +46,14 @@ pub const Daemon = struct { } var profile_manager = ProfileManager.init(allocator, power_profiles, config); + errdefer profile_manager.deinit(allocator); try ProfileLoader.loadProfiles(allocator, &profile_manager.profiles, &profile_manager.proton_profile, oneshot, config.profile_mode); const current_time = std.time.nanoTimestamp(); try scx_scheds.init(allocator); const self = try allocator.create(Self); + errdefer allocator.destroy(self); self.* = .{ .allocator = allocator, .config_path = config_path_owned,