screencopy: safer iteration of vector in destroyStream

This commit is contained in:
Vaxry 2023-11-20 18:52:06 +00:00
parent 716da5e0f3
commit 11009ba077

View file

@ -1009,7 +1009,13 @@ void CPipewireConnection::destroyStream(CScreencopyPortal::SSession* pSession) {
return; return;
if (!PSTREAM->buffers.empty()) { if (!PSTREAM->buffers.empty()) {
std::vector<SBuffer*> bufs;
for (auto& b : PSTREAM->buffers) { for (auto& b : PSTREAM->buffers) {
bufs.push_back(b.get());
}
for (auto& b : bufs) {
pwStreamRemoveBuffer(PSTREAM, b->pwBuffer); pwStreamRemoveBuffer(PSTREAM, b->pwBuffer);
} }
} }