git.lucas.co / cce-compositor
Wayland compositor (wlroots)
git clone https://git.lucas.co/cce-compositor.git

commit00695161827c635bf310bb7ad75ed1609d1809f8
parentb4f1a488e9
authorIsaac Freund <[email protected]>
date2023-01-07 17:35
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,