Skip to content

Commit

Permalink
client: Set queued buffer busy
Browse files Browse the repository at this point in the history
From the outside it doesn't matter if the buffer was really committed
or queued, it still in use. If it is not marked  busy QWaylandShmBackingStore
will delete when it is resized which can happen when the surface changes
screens or receives a new fractional scale resulting in a use after free
producing a crash or protocol error.

Pick-to: 6.6
Change-Id: I8abc4edbd8990af5114aa0b36c8ecedb37a4f0f6
Reviewed-by: David Edmundson <[email protected]>
Reviewed-by: Kai Uwe Broulik <[email protected]>
  • Loading branch information
Sodivad committed Aug 3, 2023
1 parent fa2a7b2 commit 39a0039
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/client/qwaylandbuffer_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Q_WAYLANDCLIENT_EXPORT QWaylandBuffer {
virtual QSize size() const = 0;
virtual int scale() const { return 1; }

void setBusy() { mBusy = true; }
void setBusy(bool busy) { mBusy = busy; }
bool busy() const { return mBusy; }

void setCommitted() { mCommitted = true; }
Expand Down
6 changes: 5 additions & 1 deletion src/client/qwaylandwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ void QWaylandWindow::attach(QWaylandBuffer *buffer, int x, int y)
if (buffer) {
Q_ASSERT(!buffer->committed());
handleUpdate();
buffer->setBusy();
buffer->setBusy(true);

mSurface->attach(buffer->buffer(), x, y);
} else {
Expand Down Expand Up @@ -713,7 +713,11 @@ void QWaylandWindow::safeCommit(QWaylandBuffer *buffer, const QRegion &damage)
if (isExposed()) {
commit(buffer, damage);
} else {
if (mQueuedBuffer) {
mQueuedBuffer->setBusy(false);
}
mQueuedBuffer = buffer;
mQueuedBuffer->setBusy(true);
mQueuedBufferDamage = damage;
}
}
Expand Down

0 comments on commit 39a0039

Please sign in to comment.