(ftpfs_open_socket): fix memory leak in case of proxy usage

...and remove pointless check.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2019-04-07 11:28:08 +03:00
parent f19a10c657
commit a16db591e3

View File

@ -846,34 +846,29 @@ ftpfs_open_socket (struct vfs_class *me, struct vfs_s_super *super)
int my_socket = 0; int my_socket = 0;
char *host = NULL; char *host = NULL;
char port[8]; char port[8];
int tmp_port; int tmp_port = 0;
int e; int e;
(void) me; (void) me;
/* Use a proxy host? */ if (super->path_element->host == NULL || *super->path_element->host == '\0')
host = g_strdup (super->path_element->host);
if (host == NULL || *host == '\0')
{ {
vfs_print_message ("%s", _("ftpfs: Invalid host name.")); vfs_print_message ("%s", _("ftpfs: Invalid host name."));
ftpfs_errno = EINVAL; ftpfs_errno = EINVAL;
g_free (host);
return (-1); return (-1);
} }
/* Use a proxy host? */
/* Hosts to connect to that start with a ! should use proxy */ /* Hosts to connect to that start with a ! should use proxy */
tmp_port = super->path_element->port;
if (FTP_SUPER (super)->proxy != NULL) if (FTP_SUPER (super)->proxy != NULL)
ftpfs_get_proxy_host_and_port (ftpfs_proxy_host, &host, &tmp_port); ftpfs_get_proxy_host_and_port (ftpfs_proxy_host, &host, &tmp_port);
else
{
host = g_strdup (super->path_element->host);
tmp_port = super->path_element->port;
}
g_snprintf (port, sizeof (port), "%hu", (unsigned short) tmp_port); g_snprintf (port, sizeof (port), "%hu", (unsigned short) tmp_port);
if (*port == '\0')
{
g_free (host);
ftpfs_errno = errno;
return (-1);
}
tty_enable_interrupt_key (); /* clear the interrupt flag */ tty_enable_interrupt_key (); /* clear the interrupt flag */