Skip to content
This repository was archived by the owner on Apr 24, 2019. It is now read-only.

Commit b222048

Browse files
Yogesh PandeYogesh Pande
authored andcommitted
Deleting socket_address object in destructor.
1 parent 9938151 commit b222048

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

source/m2mconnectionhandlerpimpl.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ M2MConnectionHandlerPimpl::M2MConnectionHandlerPimpl(M2MConnectionHandler* base,
116116
M2MConnectionHandlerPimpl::~M2MConnectionHandlerPimpl()
117117
{
118118
tr_debug("M2MConnectionHandlerPimpl::~M2MConnectionHandlerPimpl()");
119+
if(_socket_address) {
120+
delete _socket_address;
121+
_socket_address = NULL;
122+
}
119123
if (_socket) {
120124
delete _socket;
121125
_socket = 0;
@@ -168,10 +172,10 @@ void M2MConnectionHandlerPimpl::dns_handler()
168172
}
169173
_socket_address = new SocketAddress(_net_iface,_server_address.c_str(), _server_port);
170174
if(*_socket_address) {
171-
_address._length = strlen(_socket_address->get_ip_address());
172-
memcpy(_address._address,_socket_address->get_ip_address(),_address._length);
175+
_address._address = (void*)_socket_address->get_ip_address();
173176
tr_debug("IP Address %s",_socket_address->get_ip_address());
174-
tr_debug("Port %d",_socket_address->get_port());
177+
tr_debug("Port %d",_socket_address->get_port());
178+
_address._length = strlen((char*)_address._address);
175179
_address._port = _socket_address->get_port();
176180
_address._stack = _network_stack;
177181
} else {

0 commit comments

Comments
 (0)