From 445a784ef3dc9995d071ae2aefc238f4869d071c Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Mon, 9 Dec 2024 14:51:14 +0000 Subject: [PATCH] backends/x11: Fix a crash in KWin::X11WindowedEglPrimaryLayer::present() CompositorWayland will call the present() function even if the beginFrame() fails, in which case, m_buffer can be null. Also, the present function has no code to reset m_buffer after it has finished using it. SENTRY: KWIN-6JD (cherry picked from commit 1573657c2d48442a1b2bd55d2e7feefecb596ec8) Co-authored-by: Vlad Zahorodnii --- src/backends/x11/windowed/x11_windowed_egl_backend.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/backends/x11/windowed/x11_windowed_egl_backend.cpp b/src/backends/x11/windowed/x11_windowed_egl_backend.cpp index 20f7e45fc3..8cb4501df8 100644 --- a/src/backends/x11/windowed/x11_windowed_egl_backend.cpp +++ b/src/backends/x11/windowed/x11_windowed_egl_backend.cpp @@ -76,6 +76,10 @@ bool X11WindowedEglPrimaryLayer::doEndFrame(const QRegion &renderedRegion, const void X11WindowedEglPrimaryLayer::present() { + if (!m_buffer) { + return; + } + xcb_pixmap_t pixmap = m_output->importBuffer(m_buffer->buffer()); Q_ASSERT(pixmap != XCB_PIXMAP_NONE); @@ -105,6 +109,7 @@ void X11WindowedEglPrimaryLayer::present() EGLNativeFence releaseFence{m_backend->eglDisplayObject()}; m_swapchain->release(m_buffer, releaseFence.fileDescriptor().duplicate()); + m_buffer = nullptr; } std::shared_ptr X11WindowedEglPrimaryLayer::texture() const