Clamp user session index if invalid

Signed-off-by: AnErrupTion <anerruption@disroot.org>
This commit is contained in:
AnErrupTion
2025-12-30 18:09:46 +01:00
parent 26e7585b0b
commit 8e893932f2
2 changed files with 2 additions and 3 deletions

View File

@@ -529,7 +529,7 @@ pub fn main() !void {
active_input = .password; active_input = .password;
if (user.session_index < session.label.list.items.len) session.label.current = user.session_index; session.label.current = @min(user.session_index, session.label.list.items.len - 1);
} }
} }

View File

@@ -71,8 +71,7 @@ pub fn getCurrentUsername(self: UserList) []const u8 {
fn usernameChanged(user: User, maybe_session: ?*Session) void { fn usernameChanged(user: User, maybe_session: ?*Session) void {
if (maybe_session) |session| { if (maybe_session) |session| {
if (user.session_index.* >= session.label.list.items.len) return; session.label.current = @min(user.session_index.*, session.label.list.items.len - 1);
session.label.current = user.session_index.*;
} }
} }