[balsa/wip/gtk4: 222/351] Do not leak strings



commit 4e39dc7fa55d90cd0595420daf1c4583d66c60d0
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Thu Mar 15 12:04:58 2018 -0400

    Do not leak strings

 libbalsa/imap-server.c |    1 +
 libbalsa/smtp-server.c |   21 ++++++++++-----------
 src/mailbox-conf.c     |   14 ++++++++++----
 3 files changed, 21 insertions(+), 15 deletions(-)
---
diff --git a/libbalsa/imap-server.c b/libbalsa/imap-server.c
index ed20750..fa1c3eb 100644
--- a/libbalsa/imap-server.c
+++ b/libbalsa/imap-server.c
@@ -582,6 +582,7 @@ libbalsa_imap_server_new_from_config(void)
             g_clear_pointer(&passwd, libbalsa_free_password);
         }
         libbalsa_server_set_password(server, passwd);
+        libbalsa_free_password(passwd);
     }
     return imap_server;
 }
diff --git a/libbalsa/smtp-server.c b/libbalsa/smtp-server.c
index c4f59db..02697fb 100644
--- a/libbalsa/smtp-server.c
+++ b/libbalsa/smtp-server.c
@@ -87,6 +87,9 @@ static void
 libbalsa_smtp_server_init(LibBalsaSmtpServer * smtp_server)
 {
     libbalsa_server_set_protocol(LIBBALSA_SERVER(smtp_server), "smtp");
+
+    /* Change the default. */
+    libbalsa_server_set_remember_passwd(LIBBALSA_SERVER(smtp_server), TRUE);
 }
 
 /* Class boilerplate */
@@ -121,10 +124,6 @@ libbalsa_smtp_server_get_type(void)
 
 /**
  * libbalsa_smtp_server_new:
- * @username: username to use to login
- * @host: hostname of server
- *
- * Creates or recycles a #LibBalsaSmtpServer matching the host+username pair.
  *
  * Return value: A #LibBalsaSmtpServer
  */
@@ -135,9 +134,6 @@ libbalsa_smtp_server_new(void)
 
     smtp_server = g_object_new(LIBBALSA_TYPE_SMTP_SERVER, NULL);
 
-    /* Change the default. */
-    libbalsa_server_set_remember_passwd(LIBBALSA_SERVER(smtp_server), TRUE);
-
     return smtp_server;
 }
 
@@ -307,6 +303,7 @@ smtp_server_response(GtkDialog * dialog, gint response,
 {
     LibBalsaServer *server = LIBBALSA_SERVER(sdi->smtp_server);
     GError *error = NULL;
+    gchar *filename;
 
     switch (response) {
     case GTK_RESPONSE_HELP:
@@ -342,12 +339,14 @@ smtp_server_response(GtkDialog * dialog, gint response,
         libbalsa_server_set_client_cert
             (server,
              gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(sdi->cert_button)));
-        libbalsa_server_set_cert_file
-            (server,
-             gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(sdi->cert_file)));
+
+        filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(sdi->cert_file));
+        libbalsa_server_set_cert_file(server, filename);
+        g_free(filename);
+
         libbalsa_server_set_cert_passphrase
             (server,
-             gtk_editable_get_chars(GTK_EDITABLE(sdi->cert_pass), 0, -1));
+             gtk_entry_get_text(GTK_ENTRY(sdi->cert_pass)));
         if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(sdi->split_button))) {
             /* big_message is stored in kB, but the widget is in MB. */
                sdi->smtp_server->big_message =
diff --git a/src/mailbox-conf.c b/src/mailbox-conf.c
index d6226c3..6fd443b 100644
--- a/src/mailbox-conf.c
+++ b/src/mailbox-conf.c
@@ -890,6 +890,7 @@ update_pop_mailbox(MailboxConfWindow *mcw)
        LibBalsaMailboxPop3 *mailbox;
        LibBalsaServer *server;
        BalsaServerConf *bsc;
+        gchar *filename;
 
        mailbox = LIBBALSA_MAILBOX_POP3(mcw->mailbox);
        server = LIBBALSA_MAILBOX_REMOTE_GET_SERVER(mailbox);
@@ -901,7 +902,7 @@ update_pop_mailbox(MailboxConfWindow *mcw)
             gtk_editable_get_chars(GTK_EDITABLE(mcw->mailbox_name), 0, -1);
 
        libbalsa_server_set_host(server, gtk_entry_get_text(GTK_ENTRY(mcw->mb_data.pop3.bsc.server)), FALSE);
- libbalsa_server_set_security(server, gtk_combo_box_get_active(GTK_COMBO_BOX(mcw->mb_data.pop3.security)) + 
1);
+        libbalsa_server_set_security(server, 
gtk_combo_box_get_active(GTK_COMBO_BOX(mcw->mb_data.pop3.security)) + 1);
 
        libbalsa_server_set_username(server, gtk_entry_get_text(GTK_ENTRY(mcw->mb_data.pop3.username)));
        libbalsa_server_set_password(server, gtk_entry_get_text(GTK_ENTRY(mcw->mb_data.pop3.password)));
@@ -915,9 +916,14 @@ update_pop_mailbox(MailboxConfWindow *mcw)
             gtk_editable_get_chars(GTK_EDITABLE(mcw->mb_data.pop3.filter_cmd), 0, -1);
 
        /* advanced settings */
- libbalsa_server_set_client_cert(server, 
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(bsc->need_client_cert)));
- libbalsa_server_set_cert_file(server, 
g_strdup(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(bsc->client_cert_file))));;
- libbalsa_server_set_cert_passphrase(server, gtk_editable_get_chars(GTK_EDITABLE(bsc->client_cert_passwd), 
0, -1));
+        libbalsa_server_set_client_cert(server, 
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(bsc->need_client_cert)));
+
+        filename =
+            gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(bsc->client_cert_file));
+        libbalsa_server_set_cert_file(server, filename);
+        g_free(filename);
+
+        libbalsa_server_set_cert_passphrase(server, gtk_entry_get_text(GTK_ENTRY(bsc->client_cert_passwd)));
        mailbox->disable_apop = 
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mcw->mb_data.pop3.disable_apop));
        mailbox->enable_pipe = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mcw->mb_data.pop3.enable_pipe));
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]