mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
fixed possible crash in rsnet.cc
This commit is contained in:
parent
74bb3b6a8b
commit
8fdf8f81a8
@ -81,13 +81,13 @@ bool rsGetHostByName(const std::string& hostname, in_addr& returned_addr)
|
||||
addrinfo *info = NULL;
|
||||
int res = getaddrinfo(hostname.c_str(),NULL,NULL,&info) ;
|
||||
|
||||
if(res > 0)
|
||||
if(res > 0 || info == NULL || info->ai_addr == NULL)
|
||||
{
|
||||
std::cerr << "(EE) getaddrinfo returned error " << res << " on string \"" << hostname << "\"" << std::endl;
|
||||
returned_addr.s_addr = 0 ;
|
||||
}
|
||||
else
|
||||
returned_addr.s_addr = ((sockaddr_in*)info->ai_addr)->sin_addr.s_addr ;
|
||||
returned_addr.s_addr = ((sockaddr_in*)info->ai_addr)->sin_addr.s_addr ;
|
||||
|
||||
freeaddrinfo(info) ;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user