Blame SOURCES/volume_key-0.3.12-fix_resource_leaks.patch

7f5a10
diff --git a/lib/kmip.c b/lib/kmip.c
7f5a10
index dda819a..333603c 100644
7f5a10
--- a/lib/kmip.c
7f5a10
+++ b/lib/kmip.c
7f5a10
@@ -1152,6 +1152,7 @@ kmip_decode_key_value (struct kmip_decoding_state *kmip,
7f5a10
       break;
7f5a10
 
7f5a10
     default:
7f5a10
+      kmip_key_value_free (res);
7f5a10
       g_return_val_if_reached (-1);
7f5a10
     }
7f5a10
   res->attributes = g_ptr_array_new ();
7f5a10
@@ -1348,6 +1349,7 @@ kmip_decode_object_symmetric_key (struct kmip_decoding_state *kmip,
7f5a10
       g_snprintf (num, sizeof (num), "%" G_GUINT32_FORMAT, res->block->type);
7f5a10
       g_set_error (error, LIBVK_ERROR, LIBVK_ERROR_KMIP_UNSUPPORTED_VALUE,
7f5a10
 		   _("Unsupported symmetric key format %s"), num);
7f5a10
+      kmip_object_symmetric_key_free (res);
7f5a10
       return -1;
7f5a10
     }
7f5a10
   *obj = res;
7f5a10
@@ -1384,6 +1386,7 @@ kmip_decode_object_secret_data (struct kmip_decoding_state *kmip,
7f5a10
       g_snprintf (num, sizeof (num), "%" G_GUINT32_FORMAT, res->block->type);
7f5a10
       g_set_error (error, LIBVK_ERROR, LIBVK_ERROR_KMIP_UNSUPPORTED_VALUE,
7f5a10
 		   _("Unsupported symmetric key format %s"), num);
7f5a10
+      kmip_object_secret_data_free (res);
7f5a10
       return -1;
7f5a10
     }
7f5a10
   *obj = res;
7f5a10
diff --git a/lib/volume_luks.c b/lib/volume_luks.c
7f5a10
index d1c5d47..4d32d9b 100644
7f5a10
--- a/lib/volume_luks.c
7f5a10
+++ b/lib/volume_luks.c
7f5a10
@@ -547,8 +547,8 @@ luks_apply_secret (struct libvk_volume *vol, const struct libvk_volume *packet,
7f5a10
     }
7f5a10
   g_free (last_log_entry);
7f5a10
 
7f5a10
-  g_return_val_if_fail (vol->v.luks->key_bytes == packet->v.luks->key_bytes,
7f5a10
-			-1);
7f5a10
+  if (vol->v.luks->key_bytes != packet->v.luks->key_bytes)
7f5a10
+    goto err_passphrase;
7f5a10
   luks_replace_key (vol, packet->v.luks->key);
7f5a10
   luks_replace_passphrase (vol, passphrase);
7f5a10
   vol->v.luks->passphrase_slot = res;
7f5a10
diff --git a/src/volume_key.c b/src/volume_key.c
7f5a10
index 074b187..24b70d6 100644
7f5a10
--- a/src/volume_key.c
7f5a10
+++ b/src/volume_key.c
7f5a10
@@ -735,6 +735,11 @@ write_packet (struct packet_output_state *pos, const char *filename,
7f5a10
       || g_file_set_contents (filename, packet, size, error) == FALSE)
7f5a10
     {
7f5a10
       g_prefix_error (error, _("Error creating `%s': "), filename);
7f5a10
+      if (packet != NULL) {
7f5a10
+        if (output_format_cleartext != 0)
7f5a10
+          memset (packet, 0, size);
7f5a10
+        g_free (packet);
7f5a10
+      }
7f5a10
       return -1;
7f5a10
     }
7f5a10
   if (output_format_cleartext != 0)