Commit 1c09eab7 authored by Ulrich Sibiller's avatar Ulrich Sibiller Committed by Mihai Moldovan

Loop.cpp: fix two memleaks

parent c4660e10
...@@ -4278,15 +4278,20 @@ int ListenConnectionTCP(const char *host, long port, const char *label) ...@@ -4278,15 +4278,20 @@ int ListenConnectionTCP(const char *host, long port, const char *label)
int ListenConnection(ChannelEndPoint &endpoint, const char *label) int ListenConnection(ChannelEndPoint &endpoint, const char *label)
{ {
char *unixPath, *host; char *unixPath = NULL, *host = NULL;
long port; long port;
int result = -1;
if (endpoint.getUnixPath(&unixPath)) { if (endpoint.getUnixPath(&unixPath)) {
return ListenConnectionUnix(unixPath, label); result = ListenConnectionUnix(unixPath, label);
} }
else if (endpoint.getTCPHostAndPort(&host, &port)) { else if (endpoint.getTCPHostAndPort(&host, &port)) {
return ListenConnectionTCP(host, port, label); result = ListenConnectionTCP(host, port, label);
} }
return -1; free(unixPath);
unixPath = NULL;
free(host);
host = NULL;
return result;
} }
static int AcceptConnection(int fd, int domain, const char *label) static int AcceptConnection(int fd, int domain, const char *label)
...@@ -6739,10 +6744,20 @@ int ConnectToRemote(ChannelEndPoint &socketAddress) ...@@ -6739,10 +6744,20 @@ int ConnectToRemote(ChannelEndPoint &socketAddress)
} }
} }
free(unixPath);
unixPath = NULL;
free(hostName);
hostName = NULL;
return pFD; return pFD;
ConnectToRemoteError: ConnectToRemoteError:
free(unixPath);
unixPath = NULL;
free(hostName);
hostName = NULL;
if (pFD != -1) if (pFD != -1)
{ {
close(pFD); close(pFD);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment