From 1a7c94b69285d3e5f5f26ca9b0214f49fe101b16 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Mon, 17 Jun 2024 13:33:41 +0300 Subject: [PATCH] wayland: Fix buffer ref'ing in org_kde_kwin_shadow.commit In case the current state and the pending state have the same buffer for a particular side or a corner, that buffer can be prematurely released because the buffer in the current state is unreferenced first. The ref/unref order should be vice versa to ensure that the GraphicsBuffer is not released prematurely. --- src/wayland/shadow.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/wayland/shadow.cpp b/src/wayland/shadow.cpp index 1a6e5eed46..4b831e5446 100644 --- a/src/wayland/shadow.cpp +++ b/src/wayland/shadow.cpp @@ -139,12 +139,12 @@ void ShadowInterfacePrivate::org_kde_kwin_shadow_commit(Resource *resource) { #define BUFFER(__FLAG__, __PART__) \ if (pending.flags & State::Flags::__FLAG__##Buffer) { \ - if (current.__PART__) { \ - current.__PART__->unref(); \ - } \ if (pending.__PART__) { \ pending.__PART__->ref(); \ } \ + if (current.__PART__) { \ + current.__PART__->unref(); \ + } \ current.__PART__ = pending.__PART__; \ } BUFFER(Left, left)