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,8 +36,18 @@ namespace RTC ...@@ -36,8 +36,18 @@ namespace RTC
MS_THROW_ERROR("invalid destination IP '%s'", options.remoteIP.c_str()); MS_THROW_ERROR("invalid destination IP '%s'", options.remoteIP.c_str());
// This may throw. // This may throw.
try
{
SetRemoteParameters(options.remoteIP.c_str(), options.remotePort); 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. // No remote IP address is provided.
else else
{ {
...@@ -73,6 +83,7 @@ namespace RTC ...@@ -73,6 +83,7 @@ namespace RTC
{ {
MS_TRACE(); MS_TRACE();
if (this->tuple != nullptr)
delete this->tuple; delete this->tuple;
if (this->udpSocket != nullptr) if (this->udpSocket != nullptr)
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论