mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-12-22 09:24:54 +01:00
mime-node: Clean up unwrapped MIME parts correctly.
Avoid a memory leak in the notmuch command line. gmime_multipart_encrypted_decrypt returns a GMimeObject marked by GMime as "transfer full", so we are supposed to clean up after it. When parsing a message, notmuch would leak one GMimeObject part per multipart/encrypted MIME layer. We clean it up by analogy with cleaning up the signature list associated with a MIME node. Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
This commit is contained in:
parent
7de3d77d2d
commit
4dccb99282
1 changed files with 22 additions and 0 deletions
22
mime-node.c
22
mime-node.c
|
@ -192,6 +192,26 @@ set_signature_list_destructor (mime_node_t *node)
|
|||
}
|
||||
}
|
||||
|
||||
/* Unwrapped MIME part destructor */
|
||||
static int
|
||||
_unwrapped_child_free (GMimeObject **proxy)
|
||||
{
|
||||
g_object_unref (*proxy);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Set up unwrapped MIME part destructor */
|
||||
static void
|
||||
set_unwrapped_child_destructor (mime_node_t *node)
|
||||
{
|
||||
GMimeObject **proxy = talloc (node, GMimeObject *);
|
||||
|
||||
if (proxy) {
|
||||
*proxy = node->unwrapped_child;
|
||||
talloc_set_destructor (proxy, _unwrapped_child_free);
|
||||
}
|
||||
}
|
||||
|
||||
/* Verify a signed mime node */
|
||||
static void
|
||||
node_verify (mime_node_t *node, GMimeObject *part)
|
||||
|
@ -238,6 +258,8 @@ node_decrypt_and_verify (mime_node_t *node, GMimeObject *part)
|
|||
node->ctx->crypto->decrypt,
|
||||
message,
|
||||
encrypteddata, &decrypt_result, &err);
|
||||
if (node->unwrapped_child)
|
||||
set_unwrapped_child_destructor (node);
|
||||
}
|
||||
if (! node->unwrapped_child) {
|
||||
fprintf (stderr, "Failed to decrypt part: %s\n",
|
||||
|
|
Loading…
Reference in a new issue