diff options
Diffstat (limited to 'src/socket/Socket.cpp')
-rw-r--r-- | src/socket/Socket.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/socket/Socket.cpp b/src/socket/Socket.cpp index 97411b64..9192217b 100644 --- a/src/socket/Socket.cpp +++ b/src/socket/Socket.cpp @@ -70,9 +70,16 @@ Socket::Socket(Type t, { } +Socket::~Socket() +{ + free(_addr); + close(); +} + bool Socket::set_addr(const std::string& uri) { + free(_addr); if (_type == UNIX && uri.substr(0, strlen("unix://")) == "unix://") { const std::string path = uri.substr(strlen("unix://")); struct sockaddr_un* uaddr = (struct sockaddr_un*)calloc( @@ -105,6 +112,7 @@ Socket::set_addr(const std::string& uri) _addr = (struct sockaddr*)malloc(ainfo->ai_addrlen); _addr_len = ainfo->ai_addrlen; memcpy(_addr, ainfo->ai_addr, ainfo->ai_addrlen); + freeaddrinfo(ainfo); return true; } return false; |