Don't forget to allocate :D

Signed-off-by: AnErrupTion <anerruption@disroot.org>
This commit is contained in:
AnErrupTion
2025-12-30 17:43:00 +01:00
parent b1cb576f67
commit 26e7585b0b
3 changed files with 4 additions and 12 deletions

View File

@@ -17,7 +17,6 @@ entry_ini: ?Ini(Entry) = null,
file_name: []const u8 = "",
name: []const u8 = "",
xdg_session_desktop: ?[]const u8 = null,
xdg_session_desktop_owned: bool = false,
xdg_desktop_names: ?[]const u8 = null,
cmd: ?[]const u8 = null,
specifier: []const u8 = "",

View File

@@ -1251,11 +1251,10 @@ fn crawl(session: *Session, lang: Lang, path: []const u8, display_server: Displa
});
errdefer entry_ini.deinit();
const file_name = std.fs.path.stem(item.name);
const file_name = try session.label.allocator.dupe(u8, std.fs.path.stem(item.name));
const entry = entry_ini.data.@"Desktop Entry";
var maybe_xdg_session_desktop: ?[]const u8 = null;
var maybe_xdg_desktop_names: ?[]const u8 = null;
var xdg_session_desktop_owned = false;
// Prepare the XDG_SESSION_DESKTOP and XDG_CURRENT_DESKTOP environment
// variables here
@@ -1269,18 +1268,14 @@ fn crawl(session: *Session, lang: Lang, path: []const u8, display_server: Displa
} else if (display_server != .custom) {
// If DesktopNames is empty, and this isn't a custom session entry,
// we'll take the name of the session file
if (file_name.len > 0) {
maybe_xdg_session_desktop = try session.label.allocator.dupe(u8, file_name);
xdg_session_desktop_owned = true;
}
if (file_name.len > 0) maybe_xdg_session_desktop = file_name;
}
try session.addEnvironment(.{
.entry_ini = entry_ini,
.file_name = std.fs.path.stem(item.name),
.file_name = file_name,
.name = entry.Name,
.xdg_session_desktop = maybe_xdg_session_desktop,
.xdg_session_desktop_owned = xdg_session_desktop_owned,
.xdg_desktop_names = maybe_xdg_desktop_names,
.cmd = entry.Exec,
.specifier = switch (display_server) {

View File

@@ -29,9 +29,7 @@ pub fn init(allocator: Allocator, buffer: *TerminalBuffer, user_list: *UserList)
pub fn deinit(self: *Session) void {
for (self.label.list.items) |*env| {
if (env.environment.entry_ini) |*entry_ini| entry_ini.deinit();
if (env.environment.xdg_session_desktop_owned) {
self.label.allocator.free(env.environment.xdg_session_desktop.?);
}
self.label.allocator.free(env.environment.file_name);
}
self.label.deinit();