From d75ef06bf4df4d4e9b4caa6f0722476d9e3f09b4 Mon Sep 17 00:00:00 2001 From: Tom Englund Date: Thu, 1 Aug 2024 10:46:58 +0200 Subject: [PATCH] buffer: fix buffer crash current buffer->buffer can turn out to be null actually check for its existence or use the lastbuffer when calling updateCursorShm() --- src/protocols/core/Compositor.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/protocols/core/Compositor.cpp b/src/protocols/core/Compositor.cpp index 81be8e46d68..bff5213317e 100644 --- a/src/protocols/core/Compositor.cpp +++ b/src/protocols/core/Compositor.cpp @@ -480,14 +480,14 @@ void CWLSurfaceResource::commitPendingState() { } void CWLSurfaceResource::updateCursorShm() { - auto buf = current.buffer ? current.buffer : lastBuffer; + auto buf = current.buffer ? current.buffer->buffer : lastBuffer; if (!buf) return; // TODO: actually use damage auto& shmData = CCursorSurfaceRole::cursorPixelData(self.lock()); - auto shmAttrs = current.buffer->buffer->shm(); + auto shmAttrs = buf->shm(); if (!shmAttrs.success) { LOGM(TRACE, "updateCursorShm: ignoring, not a shm buffer"); @@ -495,7 +495,7 @@ void CWLSurfaceResource::updateCursorShm() { } // no need to end, shm. - auto [pixelData, fmt, bufLen] = current.buffer->buffer->beginDataPtr(0); + auto [pixelData, fmt, bufLen] = buf->beginDataPtr(0); shmData.resize(bufLen); memcpy(shmData.data(), pixelData, bufLen);