X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=mime-node.c;h=ff6805bf020998e33c45ce5657cf93f79b5a647b;hp=2a823dfdcbd75c1f679041099555580d720fdd24;hb=02112728433cb08ea2501d937a2ca3cb73a0d85b;hpb=7de3d77d2d31abaea78e70f4da9d9f2a5ef84a58 diff --git a/mime-node.c b/mime-node.c index 2a823dfd..ff6805bf 100644 --- a/mime-node.c +++ b/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",