Skip to content

Commit c70f83f

Browse files
ibclavarsicious
authored andcommitted
Fix a crash when there are no more available ports (fixes versatica#222)
- The destructor of ~Transport was being called twice
1 parent b989605 commit c70f83f

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

worker/src/RTC/WebRtcTransport.cpp

+17-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,23 @@ namespace RTC
163163
// Ensure there is at least one IP:port binding.
164164
if (this->udpSockets.empty() && this->tcpServers.empty())
165165
{
166-
delete this;
166+
// NOTE: We must manually delete above allocated objects. We cannot call `delete this`
167+
// here since it would call the parent ~Transport destructor, and it would be called
168+
// again after throwing the exception here.
169+
//
170+
// See: https://github.com/versatica/mediasoup/issues/222
171+
172+
this->iceServer->Destroy();
173+
174+
for (auto* socket : this->udpSockets)
175+
{
176+
socket->Destroy();
177+
}
178+
179+
for (auto* server : this->tcpServers)
180+
{
181+
server->Destroy();
182+
}
167183

168184
MS_THROW_ERROR("could not open any IP:port");
169185
}

0 commit comments

Comments
 (0)