...and one more forgotten NULL check.
[claws.git] / src / passwordstore.c
index f67048c19b8ff82fe3da9e1f485c020435d4fcc3..0564d473b0ea982944d2de8ae4788b21ecfb8a19 100644 (file)
@@ -122,11 +122,6 @@ gboolean passwd_store_set(PasswordBlockType block_type,
        else
                p = password;
 
-       debug_print("%s password '%s' in block (%d/%s)%s\n",
-                       (p == NULL ? "Deleting" : "Storing"),
-                       password_id, block_type, block_name,
-                       (encrypted ? ", already encrypted" : "") );
-
        /* find correct block (create if needed) */
        if ((block = _get_block(block_type, block_name)) == NULL) {
                /* If caller wants to delete a password, and even its block
@@ -141,6 +136,11 @@ gboolean passwd_store_set(PasswordBlockType block_type,
                }
        }
 
+       debug_print("%s password for '%s' in block (%d/%s)%s\n",
+                       (p == NULL ? "Deleting" : "Storing"),
+                       password_id, block_type, block_name,
+                       (encrypted ? ", already encrypted" : "") );
+
        if (p == NULL) {
                /* NULL password was passed to us, so delete the entry with
                 * corresponding id */
@@ -307,7 +307,7 @@ void passwd_store_reencrypt_all(const gchar *old_mpwd,
                debug_print("Reencrypting passwords in block (%d/%s).\n",
                                block->block_type, block->block_name);
 
-               if (g_hash_table_size(block->entries) == 0)
+               if (block->entries == NULL || g_hash_table_size(block->entries) == 0)
                        continue;
 
                keys = g_hash_table_get_keys(block->entries);
@@ -369,7 +369,7 @@ static gint _write_to_file(FILE *fp)
                        continue; /* Just in case. */
 
                /* Do not save empty blocks. */
-               if (g_hash_table_size(block->entries) == 0)
+               if (block->entries == NULL || g_hash_table_size(block->entries) == 0)
                        continue;
 
                /* Prepare the section header string and write it out. */