Fix possible memory corruption in the Connect to Server... dialog.
authorAndriy Grytsenko <andrej@rep.kiev.ua>
Fri, 19 Feb 2016 20:06:28 +0000 (22:06 +0200)
committerAndriy Grytsenko <andrej@rep.kiev.ua>
Fri, 19 Feb 2016 20:10:50 +0000 (22:10 +0200)
The scheme variable shouldn't be freed before using it.

NEWS
src/connect-server.c

diff --git a/NEWS b/NEWS
index d15ae84..8170d11 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -29,6 +29,8 @@
 * Fixed not working Connect to Server... dialog when non-anonymous user
     is selected.
 
+* Fixed possible memory corruption in the Connect to Server... dialog.
+
 
 Changes on 1.2.3 since 1.2.2:
 
index addb70b..d7112c8 100644 (file)
@@ -56,11 +56,6 @@ static void on_response(GtkDialog *dialog, gint resp, ConnectDlg *dlg)
     {
         /* make an URI from the data */
         str = g_string_new(scheme);
-        g_free(scheme);
-        g_string_append(str, "://");
-        if (gtk_toggle_button_get_active(dlg->user_user))
-            g_string_append_printf(str, "%s@", gtk_entry_get_text(dlg->login_entry));
-        g_string_append(str, gtk_entry_get_text(dlg->server_host));
         if (strcmp(scheme, "sftp") == 0)
             def_port = 22;
         else if (strcmp(scheme, "ftp") == 0)
@@ -69,6 +64,11 @@ static void on_response(GtkDialog *dialog, gint resp, ConnectDlg *dlg)
             def_port = 80;
         else
             def_port = -1;
+        g_free(scheme);
+        g_string_append(str, "://");
+        if (gtk_toggle_button_get_active(dlg->user_user))
+            g_string_append_printf(str, "%s@", gtk_entry_get_text(dlg->login_entry));
+        g_string_append(str, gtk_entry_get_text(dlg->server_host));
         used_port = (int)gtk_spin_button_get_value(dlg->server_port);
         if (def_port != used_port)
             g_string_append_printf(str, ":%d", used_port);