Commit ce293647 authored by Ulrich Sibiller's avatar Ulrich Sibiller

ChannelEndPoint.cpp: fix possible memleak in getUnixPath()

parent 17d04582
...@@ -207,7 +207,10 @@ ChannelEndPoint::getPort(long *port) const { ...@@ -207,7 +207,10 @@ ChannelEndPoint::getPort(long *port) const {
bool bool
ChannelEndPoint::getUnixPath(char **unixPath) const { ChannelEndPoint::getUnixPath(char **unixPath) const {
if (unixPath) *unixPath = NULL; if (unixPath)
*unixPath = NULL;
else
return false;
long p; long p;
char *path = NULL; char *path = NULL;
...@@ -227,7 +230,6 @@ ChannelEndPoint::getUnixPath(char **unixPath) const { ...@@ -227,7 +230,6 @@ ChannelEndPoint::getUnixPath(char **unixPath) const {
return false; return false;
} }
if (unixPath)
*unixPath = strdup(path); *unixPath = strdup(path);
return true; return true;
......
...@@ -6661,6 +6661,7 @@ int ConnectToRemote(ChannelEndPoint &socketAddress) ...@@ -6661,6 +6661,7 @@ int ConnectToRemote(ChannelEndPoint &socketAddress)
<< "'.\n" << std::flush; << "'.\n" << std::flush;
SAFE_FREE(hostName); SAFE_FREE(hostName);
SAFE_FREE(unixPath);
if (socketAddress.getUnixPath(&unixPath)) if (socketAddress.getUnixPath(&unixPath))
result = PrepareProxyConnectionUnix(&unixPath, &connectTimeout, &pFD, &reason); result = PrepareProxyConnectionUnix(&unixPath, &connectTimeout, &pFD, &reason);
......
...@@ -6123,7 +6123,7 @@ int Proxy::handleNewSlaveConnection(int clientFd) ...@@ -6123,7 +6123,7 @@ int Proxy::handleNewSlaveConnection(int clientFd)
int Proxy::handleNewGenericConnectionFromProxy(int channelId, T_channel_type type, int Proxy::handleNewGenericConnectionFromProxy(int channelId, T_channel_type type,
ChannelEndPoint &endPoint, const char *label) ChannelEndPoint &endPoint, const char *label)
{ {
char *unixPath, *host = NULL; char *unixPath = NULL, *host = NULL;
long port; long port;
if (endPoint.getUnixPath(&unixPath)) { if (endPoint.getUnixPath(&unixPath)) {
......
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