Fix a leak and g_log() in case of null passwords
authorColin Leroy <colin@colino.net>
Thu, 11 Feb 2016 09:25:06 +0000 (10:25 +0100)
committerColin Leroy <colin@colino.net>
Thu, 11 Feb 2016 09:25:06 +0000 (10:25 +0100)
src/prefs_gtk.c

index 68840bf0f435ce34d28bfb3086f4f1b33159b696..f6cd077c62dbfad1d9d6db35e87f4740b05038c4 100644 (file)
@@ -668,7 +668,7 @@ void prefs_set_escaped_data_from_entry(PrefParam *pparam)
 void prefs_set_entry(PrefParam *pparam)
 {
        gchar **str;
-
+    char *decrypted_pass = NULL;
        cm_return_if_fail(*pparam->widget != NULL);
 
        switch (pparam->type) {
@@ -687,8 +687,10 @@ void prefs_set_entry(PrefParam *pparam)
                break;
        case P_PASSWORD:
                str = (gchar **)pparam->data;
+        decrypted_pass = password_decrypt(*str, NULL);
                gtk_entry_set_text(GTK_ENTRY(*pparam->widget),
-                               password_decrypt(*str, NULL));
+                               (decrypted_pass != NULL ? decrypted_pass : ""));
+        g_free(decrypted_pass);
                break;
        default:
                g_warning("Invalid PrefType for GtkEntry widget: %d",