Unverified 提交 4a1d8661 authored 作者: José Luis Millán's avatar José Luis Millán 提交者: GitHub

close #224. Avoid memory leak when PlainRtpTransport constructor throws (#225)

上级 d12ee932
......@@ -36,7 +36,17 @@ namespace RTC
MS_THROW_ERROR("invalid destination IP '%s'", options.remoteIP.c_str());
// This may throw.
SetRemoteParameters(options.remoteIP.c_str(), options.remotePort);
try
{
SetRemoteParameters(options.remoteIP.c_str(), options.remotePort);
}
catch (const MediaSoupError& error)
{
// Destroy UdpSocket since ~PlainRtpTransport() will not be called.
this->udpSocket->Destroy();
throw;
}
}
// No remote IP address is provided.
else
......@@ -73,7 +83,8 @@ namespace RTC
{
MS_TRACE();
delete this->tuple;
if (this->tuple != nullptr)
delete this->tuple;
if (this->udpSocket != nullptr)
this->udpSocket->Destroy();
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论