Do not create password block when deleting a password from store.
authorAndrej Kacian <ticho@claws-mail.org>
Sat, 19 Mar 2016 19:00:57 +0000 (20:00 +0100)
committerAndrej Kacian <ticho@claws-mail.org>
Sat, 19 Mar 2016 19:00:57 +0000 (20:00 +0100)
src/passwordstore.c

index a518b7c..dfc96a0 100644 (file)
@@ -121,11 +121,17 @@ gboolean passwd_store_set(PasswordBlockType block_type,
                        (encrypted ? ", already encrypted" : "") );
 
        // find correct block (create if needed)
-       if ((block = _get_block(block_type, block_name)) == NULL &&
-                       (block = _new_block(block_type, block_name)) == NULL) {
-               debug_print("Could not create password block (%d/%s)\n",
-                               block_type, block_name);
-               return FALSE;
+       if ((block = _get_block(block_type, block_name)) == NULL) {
+               /* If caller wants to delete a password, and even its block
+                * doesn't exist, we're done. */
+               if (password == NULL)
+                       return TRUE;
+
+               if ((block = _new_block(block_type, block_name)) == NULL) {
+                       debug_print("Could not create password block (%d/%s)\n",
+                                       block_type, block_name);
+                       return FALSE;
+               }
        }
 
        if (password == NULL) {