Fix crash in vcalendar passwords handling on prefs save.
authorAndrej Kacian <ticho@claws-mail.org>
Tue, 23 Aug 2016 22:08:40 +0000 (00:08 +0200)
committerAndrej Kacian <ticho@claws-mail.org>
Tue, 23 Aug 2016 22:08:40 +0000 (00:08 +0200)
src/plugins/vcalendar/vcal_prefs.c

index 8686ba8..3968172 100644 (file)
@@ -555,16 +555,12 @@ static void vcal_prefs_create_widget_func(PrefsPage * _page,
 
        if (!vcalprefs.export_user)
                vcalprefs.export_user = g_strdup("");
-       if (!vcalprefs.export_pass)
-               vcalprefs.export_pass = g_strdup("");
        if (!vcalprefs.export_freebusy_user)
                vcalprefs.export_freebusy_user = g_strdup("");
-       if (!vcalprefs.export_freebusy_pass)
-               vcalprefs.export_freebusy_pass = g_strdup("");
 
        export_pass = vcal_passwd_get("export");
        export_freebusy_pass = vcal_passwd_get("export_freebusy");
-       
+
        gtk_entry_set_text(GTK_ENTRY(export_user_entry), vcalprefs.export_user);
        gtk_entry_set_text(GTK_ENTRY(export_pass_entry), (export_pass != NULL ? export_pass : ""));
        gtk_entry_set_text(GTK_ENTRY(export_freebusy_user_entry), vcalprefs.export_freebusy_user);
@@ -680,7 +676,6 @@ static void vcal_prefs_save_func(PrefsPage * _page)
        g_free(vcalprefs.export_user);
        vcalprefs.export_user =
            gtk_editable_get_chars(GTK_EDITABLE(page->export_user_entry), 0, -1);
-       g_free(vcalprefs.export_pass);
        pass = gtk_editable_get_chars(GTK_EDITABLE(page->export_pass_entry), 0, -1);
        
        vcal_passwd_set("export", pass);
@@ -703,7 +698,6 @@ static void vcal_prefs_save_func(PrefsPage * _page)
        g_free(vcalprefs.export_freebusy_user);
        vcalprefs.export_freebusy_user =
            gtk_editable_get_chars(GTK_EDITABLE(page->export_freebusy_user_entry), 0, -1);
-       g_free(vcalprefs.export_freebusy_pass);
        pass = gtk_editable_get_chars(GTK_EDITABLE(page->export_freebusy_pass_entry), 0, -1);
 
        vcal_passwd_set("export_freebusy", pass);
@@ -746,12 +740,16 @@ void vcal_prefs_init(void)
                passwd_store_set(PWS_PLUGIN, "vCalendar", "export",
                                vcalprefs.export_pass, TRUE);
                passwords_migrated = TRUE;
+               memset(vcalprefs.export_pass, 0, strlen(vcalprefs.export_pass));
+               g_free(vcalprefs.export_pass);
        }
        if (vcalprefs.export_freebusy_pass != NULL &&
                        strlen(vcalprefs.export_freebusy_pass) > 0) {
                passwd_store_set(PWS_PLUGIN, "vCalendar", "export",
                                vcalprefs.export_freebusy_pass, TRUE);
                passwords_migrated = TRUE;
+               memset(vcalprefs.export_freebusy_pass, 0, strlen(vcalprefs.export_freebusy_pass));
+               g_free(vcalprefs.export_freebusy_pass);
        }
 
        if (passwords_migrated)