修复rtsp组播遍历迭代器导致崩溃的bug

This commit is contained in:
xia-chu 2023-08-26 11:34:22 +08:00
parent f3f4b49332
commit cb4ab21548

View File

@ -82,10 +82,12 @@ void UDPServer::onRecv(int interleaved, const Buffer::Ptr &buf, struct sockaddr*
return; return;
} }
auto &ref = it0->second; auto &ref = it0->second;
for (auto it1 = ref.begin(); it1 != ref.end(); ++it1) { for (auto it1 = ref.begin(); it1 != ref.end();) {
auto &func = it1->second; auto &func = it1->second;
if (!func(interleaved, buf, peer_addr)) { if (!func(interleaved, buf, peer_addr)) {
it1 = ref.erase(it1); it1 = ref.erase(it1);
} else {
++it1;
} }
} }
if (ref.size() == 0) { if (ref.size() == 0) {