Skip to content

Commit

Permalink
[core] Free addrinfo if bind fails.
Browse files Browse the repository at this point in the history
  • Loading branch information
maxsharabayko authored and rndi committed Sep 12, 2019
1 parent 808a1fe commit 57b75b3
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions srtcore/channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,11 @@ void CChannel::open(const sockaddr* addr)
throw CUDTException(MJ_SETUP, MN_NORES, NET_ERROR);

// On Windows ai_addrlen has type size_t (unsigned), while bind takes int.
if (0 != ::bind(m_iSocket, res->ai_addr, (socklen_t) res->ai_addrlen))
throw CUDTException(MJ_SETUP, MN_NORES, NET_ERROR);
if (0 != ::bind(m_iSocket, res->ai_addr, (socklen_t)res->ai_addrlen))
{
::freeaddrinfo(res);
throw CUDTException(MJ_SETUP, MN_NORES, NET_ERROR);
}
memcpy(&m_BindAddr, res->ai_addr, res->ai_addrlen);
m_BindAddr.len = (socklen_t) res->ai_addrlen;

Expand Down

0 comments on commit 57b75b3

Please sign in to comment.