summaryrefslogtreecommitdiff
path: root/src/protocols
diff options
context:
space:
mode:
authormatjam <chrome@stupendous.net>2026-03-09 14:45:23 -0700
committerVaxry <43317083+vaxerski@users.noreply.github.com>2026-03-10 10:06:24 +0000
commit318673e7646796d55426c90b206abbd9d8253bf3 (patch)
tree83e7343b028b70ebbac95331a530ae41ddf960a3 /src/protocols
parentb9ddb4bb26275115e9c9ff03b3d87c6e2fd96c45 (diff)
protocols/sessionLock: fix crash when monitor is gone during lock surface creation
Move monitor signal listener registration inside the existing null guard, and validate output resource and monitor in onGetLockSurface.
Diffstat (limited to 'src/protocols')
-rw-r--r--src/protocols/SessionLock.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/protocols/SessionLock.cpp b/src/protocols/SessionLock.cpp
index 88231f38..de2b96f2 100644
--- a/src/protocols/SessionLock.cpp
+++ b/src/protocols/SessionLock.cpp
@@ -62,11 +62,11 @@ CSessionLockSurface::CSessionLockSurface(SP<CExtSessionLockSurfaceV1> resource_,
if (m_surface)
m_surface->enter(m_monitor.lock());
+
+ m_listeners.monitorMode = m_monitor->m_events.modeChanged.listen([this] { sendConfigure(); });
}
sendConfigure();
-
- m_listeners.monitorMode = m_monitor->m_events.modeChanged.listen([this] { sendConfigure(); });
}
CSessionLockSurface::~CSessionLockSurface() {
@@ -203,8 +203,17 @@ void CSessionLockProtocol::onLock(CExtSessionLockManagerV1* pMgr, uint32_t id) {
void CSessionLockProtocol::onGetLockSurface(CExtSessionLockV1* lock, uint32_t id, wl_resource* surface, wl_resource* output) {
LOGM(Log::DEBUG, "New sessionLockSurface with id {}", id);
- auto PSURFACE = CWLSurfaceResource::fromResource(surface);
- auto PMONITOR = CWLOutputResource::fromResource(output)->m_monitor.lock();
+ auto PSURFACE = CWLSurfaceResource::fromResource(surface);
+ auto OUTPUTRES = CWLOutputResource::fromResource(output);
+ if (!OUTPUTRES) {
+ LOGM(Log::ERR, "onGetLockSurface: invalid output resource");
+ return;
+ }
+ auto PMONITOR = OUTPUTRES->m_monitor.lock();
+ if (!PMONITOR) {
+ LOGM(Log::ERR, "onGetLockSurface: monitor is gone for output resource");
+ return;
+ }
SP<CSessionLock> sessionLock;
for (auto const& l : m_locks) {