fix bug 2957, 'Double-free in account preferences'
[claws.git] / src / prefs_account.c
index 2521b04a0c770396bb5374f1035dd7864b6c508c..7990a31879e81bbd16d96a91a9b7c4bdc3020247 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2011 Hiroyuki Yamamoto and the Claws Mail team
+ * Copyright (C) 1999-2013 Hiroyuki Yamamoto and the Claws Mail team
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -19,6 +19,7 @@
 
 #ifdef HAVE_CONFIG_H
 #  include "config.h"
+#include "claws-features.h"
 #endif
 
 #include "defs.h"
@@ -45,6 +46,7 @@
 #include "account.h"
 #include "mainwindow.h"
 #include "manage_window.h"
+#include "folder.h"
 #include "foldersel.h"
 #include "inc.h"
 #include "menu.h"
@@ -60,6 +62,7 @@
 #include "setup.h"
 #include "quote_fmt.h"
 #include "hooks.h"
+#include "privacy.h"
 #include "inputdialog.h"
 #include "ssl_certificate.h"
 
@@ -811,6 +814,14 @@ static PrefParam advanced_param[] = {
         &advanced_page.domain_entry,
         prefs_set_data_from_entry, prefs_set_entry},
 
+#ifdef USE_GNUTLS
+       {"gnutls_set_priority", "FALSE", &tmp_ac_prefs.set_gnutls_priority, P_BOOL,
+        NULL, NULL, NULL},
+
+       {"gnutls_priority", NULL, &tmp_ac_prefs.gnutls_priority, P_STRING,
+        NULL, NULL, NULL},
+#endif
+
 #ifndef G_OS_WIN32
        {"set_tunnelcmd", "FALSE", &tmp_ac_prefs.set_tunnelcmd, P_BOOL,
         &advanced_page.tunnelcmd_checkbtn,
@@ -903,7 +914,6 @@ static void prefs_account_edit_custom_header        (void);
 static void privacy_system_activated(GtkWidget *combobox)
 {
        const gchar *system_id;
-       gboolean privacy_enabled = FALSE;
        gint privacy_enabled_int;
        GtkTreeIter iter;
        GtkListStore *menu = GTK_LIST_STORE(gtk_combo_box_get_model(
@@ -916,11 +926,6 @@ static void privacy_system_activated(GtkWidget *combobox)
                        COMBOBOX_DATA, &privacy_enabled_int,
                        -1);
        
-       privacy_enabled = strcmp(system_id, "");
-
-       if( privacy_enabled_int == 0 )
-               privacy_enabled = FALSE;
-
        gtk_widget_set_sensitive (privacy_page.save_clear_text_checkbtn, 
                !gtk_toggle_button_get_active(
                                GTK_TOGGLE_BUTTON(privacy_page.encrypt_to_self_checkbtn)));
@@ -1207,10 +1212,6 @@ static void basic_create_widget_func(PrefsPage * _page,
                          GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
 #endif
        gtk_entry_set_visibility (GTK_ENTRY (pass_entry), FALSE);
-#ifdef MAEMO
-       hildon_gtk_entry_set_input_mode(GTK_ENTRY(pass_entry), 
-               HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_INVISIBLE);
-#endif
 
        nntpserv_label = gtk_label_new (_("News server"));
        gtk_widget_show (nntpserv_label);
@@ -1523,7 +1524,7 @@ static void receive_create_widget_func(PrefsPage * _page,
        gtk_box_pack_start (GTK_BOX (hbox2), maxarticle_label, FALSE, FALSE, 0);
 
        maxarticle_spinbtn_adj =
-               gtk_adjustment_new (300, 0, 10000, 10, 100, 0);
+               GTK_ADJUSTMENT(gtk_adjustment_new (300, 0, 10000, 10, 100, 0));
        maxarticle_spinbtn = gtk_spin_button_new
                (GTK_ADJUSTMENT (maxarticle_spinbtn_adj), 10, 0);
        gtk_widget_show (maxarticle_spinbtn);
@@ -1792,10 +1793,6 @@ static void send_create_widget_func(PrefsPage * _page,
        gtk_box_pack_start (GTK_BOX (hbox), smtp_pass_entry, TRUE, TRUE, 0);
 
        gtk_entry_set_visibility (GTK_ENTRY (smtp_pass_entry), FALSE);
-#ifdef MAEMO
-       hildon_gtk_entry_set_input_mode(GTK_ENTRY(smtp_pass_entry), 
-               HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_INVISIBLE);
-#endif
        PACK_VSPACER(vbox4, vbox_spc, VSPACING_NARROW_2);
 
        hbox = gtk_hbox_new (FALSE, 8);
@@ -3370,8 +3367,12 @@ static gboolean sslcert_get_password(gpointer source, gpointer data)
 { 
        struct GetPassData pass_data;
        /* do complicated stuff to be able to call GTK from the mainloop */
+#if !GLIB_CHECK_VERSION(2,32,0)
        pass_data.cond = g_cond_new();
-       pass_data.mutex = g_mutex_new();
+#else
+       g_cond_init(pass_data.cond);
+#endif
+       pass_data.mutex = cm_mutex_new();
        pass_data.pass = (gchar **)source;
 
        g_mutex_lock(pass_data.mutex);
@@ -3379,9 +3380,13 @@ static gboolean sslcert_get_password(gpointer source, gpointer data)
        g_idle_add(do_get_pass, &pass_data);
 
        g_cond_wait(pass_data.cond, pass_data.mutex);
+#if !GLIB_CHECK_VERSION(2,32,0)
        g_cond_free(pass_data.cond);
+#else
+       g_cond_clear(pass_data.cond);
+#endif
        g_mutex_unlock(pass_data.mutex);
-       g_mutex_free(pass_data.mutex);
+       cm_mutex_free(pass_data.mutex);
 
        return TRUE;
 }
@@ -3695,10 +3700,9 @@ PrefsAccount *prefs_account_open(PrefsAccount *ac_prefs, gboolean *dirty)
 
        if (!cancelled && dirty != NULL)
                *dirty = TRUE;
-       if (cancelled && new_account) {
-               prefs_account_free(ac_prefs);
+       if (cancelled && new_account)
                return NULL;
-       else {
+       else {
                if (ac_prefs->recv_server)
                        g_strstrip(ac_prefs->recv_server);
                if (ac_prefs->smtp_server)