From 693fa8a9686f9971ba9b04c3c93fd28591e1720d Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Tue, 12 Sep 2023 13:59:20 +0300 Subject: [PATCH] wayland: Properly clear transaction list in TransactionDmaBufLocker Transaction::unlock() can destroy buffer reference and thus also destroy TransactionDmaBufLocker. --- src/wayland/transaction.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/wayland/transaction.cpp b/src/wayland/transaction.cpp index b3bbac3707..1d207da3d6 100644 --- a/src/wayland/transaction.cpp +++ b/src/wayland/transaction.cpp @@ -45,10 +45,11 @@ TransactionDmaBufLocker::TransactionDmaBufLocker(const DmaBufAttributes *attribu notifier->setEnabled(false); m_pending.removeOne(notifier); if (m_pending.isEmpty()) { - for (Transaction *transition : std::as_const(m_transactions)) { + const auto transactions = m_transactions; // unlock() may destroy this + m_transactions.clear(); + for (Transaction *transition : transactions) { transition->unlock(); } - m_transactions.clear(); } }); m_notifiers.emplace_back(notifier);