Skip to content

Commit

Permalink
FIX(client): Fix samples double memory address allocation
Browse files Browse the repository at this point in the history
  • Loading branch information
Hartmnt committed Oct 24, 2024
1 parent 70dea60 commit c460e8c
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/mumble/AudioOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,29 @@ void AudioOutput::removeUser(const ClientUser *user) {
removeBuffer(qmOutputs.value(user));
}

#include <QDebug>

void AudioOutput::removeToken(AudioOutputToken &token) {
removeBuffer(token.m_buffer);
bool stillPlaying;
qDebug() << "Before Lock";
{
// A AudioOutputToken user can not possibly know, if
// the pointer they are holding is still valid.
// We are protected against invalid memory access and
// double-frees. But we might run into issues, if the
// system memory allocator uses the same address in quick
// succession. See #6613
qDebug() << "Locking...";
QReadLocker locker(&qrwlOutputs);
stillPlaying = qmOutputs.contains(nullptr, token.m_buffer);
qDebug() << "Unlocking...";
}

qDebug() << "After Lock. Playing: " << stillPlaying;

if (stillPlaying) {
removeBuffer(token.m_buffer);
}
token = {};
}

Expand Down

0 comments on commit c460e8c

Please sign in to comment.