From 4dd02358d92050ad55f7b3c095d8a2ea0f94f607 Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Sat, 7 Jan 2023 17:35:22 +0100 Subject: [PATCH] session-lock: fix assertion failure on abnormal client behavior If the client commits a protocol error or otherwise crashes before the session has been fully locked, we currently try to send the locked event without checking if the client has been destroyed. This commit adds the necessary if statement. --- river/LockManager.zig | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/river/LockManager.zig b/river/LockManager.zig index 6723bd4..66deff6 100644 --- a/river/LockManager.zig +++ b/river/LockManager.zig @@ -164,13 +164,15 @@ pub fn maybeLock(manager: *LockManager) void { switch (manager.state) { .waiting_for_lock_surfaces => if (all_outputs_rendered_lock_surface) { log.info("session locked", .{}); - manager.lock.?.sendLocked(); + // The lock client may have been destroyed, for example due to a protocol error. + if (manager.lock) |lock| lock.sendLocked(); manager.state = .locked; manager.lock_surfaces_timer.timerUpdate(0) catch {}; }, .waiting_for_blank => if (all_outputs_blanked) { log.info("session locked", .{}); - manager.lock.?.sendLocked(); + // The lock client may have been destroyed, for example due to a protocol error. + if (manager.lock) |lock| lock.sendLocked(); manager.state = .locked; }, .unlocked, .locked => unreachable,