From a16db591e32671bd0b69961410ac2cd18174d6e5 Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Sun, 7 Apr 2019 11:28:08 +0300 Subject: [PATCH] (ftpfs_open_socket): fix memory leak in case of proxy usage ...and remove pointless check. Signed-off-by: Andrew Borodin --- src/vfs/ftpfs/ftpfs.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/vfs/ftpfs/ftpfs.c b/src/vfs/ftpfs/ftpfs.c index 2adf1debd..674d6dc31 100644 --- a/src/vfs/ftpfs/ftpfs.c +++ b/src/vfs/ftpfs/ftpfs.c @@ -846,34 +846,29 @@ ftpfs_open_socket (struct vfs_class *me, struct vfs_s_super *super) int my_socket = 0; char *host = NULL; char port[8]; - int tmp_port; + int tmp_port = 0; int e; (void) me; - /* Use a proxy host? */ - host = g_strdup (super->path_element->host); - if (host == NULL || *host == '\0') + if (super->path_element->host == NULL || *super->path_element->host == '\0') { vfs_print_message ("%s", _("ftpfs: Invalid host name.")); ftpfs_errno = EINVAL; - g_free (host); return (-1); } + /* Use a proxy host? */ /* Hosts to connect to that start with a ! should use proxy */ - tmp_port = super->path_element->port; - if (FTP_SUPER (super)->proxy != NULL) 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); - if (*port == '\0') - { - g_free (host); - ftpfs_errno = errno; - return (-1); - } tty_enable_interrupt_key (); /* clear the interrupt flag */