Skip to content

Commit aae734a

Browse files
committed
Fix segfault when destructing udp_client
1 parent b4231e2 commit aae734a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

net_port/net_port.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const char yes = 1;
2323

2424
net_port::net_port()
2525
{
26-
26+
result_list = NULL;
2727
}
2828

2929
//net_port (constructor)
@@ -36,7 +36,10 @@ net_port::net_port(const char * client_name, const char * port)
3636

3737
net_port::~net_port()
3838
{
39-
freeaddrinfo(result_list);
39+
if(result_list)
40+
{
41+
freeaddrinfo(result_list);
42+
}
4043
}
4144

4245
bool net_port::udp_client(const char * client_name, const char * port)
@@ -76,6 +79,7 @@ bool net_port::udp_client(const char * client_name, const char * port)
7679
{
7780
memcpy(&addrDest, result_list->ai_addr, result_list->ai_addrlen);
7881
freeaddrinfo(result_list);
82+
result_list = NULL;
7983
return(true);
8084
}
8185
else

0 commit comments

Comments
 (0)