aboutsummaryrefslogtreecommitdiffstats
path: root/mail/mail-crypto.c
diff options
context:
space:
mode:
Diffstat (limited to 'mail/mail-crypto.c')
-rw-r--r--mail/mail-crypto.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/mail/mail-crypto.c b/mail/mail-crypto.c
index 7613f11eef..7fb3aba88d 100644
--- a/mail/mail-crypto.c
+++ b/mail/mail-crypto.c
@@ -154,13 +154,16 @@ mail_crypto_pgp_mime_part_sign (CamelMimePart **mime_part, const char *userid, C
CamelCipherValidity *
mail_crypto_pgp_mime_part_verify (CamelMimePart *mime_part, CamelException *ex)
{
+ CamelCipherValidity *valid = NULL;
CamelPgpContext *context;
- CamelCipherValidity *valid;
context = camel_pgp_context_new (session, mail_config_get_pgp_type (),
mail_config_get_pgp_path ());
- valid = camel_pgp_mime_part_verify (context, mime_part, ex);
- camel_object_unref (CAMEL_OBJECT (context));
+
+ if (context) {
+ valid = camel_pgp_mime_part_verify (context, mime_part, ex);
+ camel_object_unref (CAMEL_OBJECT (context));
+ }
return valid;
}
@@ -183,8 +186,11 @@ mail_crypto_pgp_mime_part_encrypt (CamelMimePart **mime_part, GPtrArray *recipie
context = camel_pgp_context_new (session, mail_config_get_pgp_type (),
mail_config_get_pgp_path ());
- camel_pgp_mime_part_encrypt (context, mime_part, recipients, ex);
- camel_object_unref (CAMEL_OBJECT (context));
+
+ if (context) {
+ camel_pgp_mime_part_encrypt (context, mime_part, recipients, ex);
+ camel_object_unref (CAMEL_OBJECT (context));
+ }
}
@@ -199,12 +205,15 @@ CamelMimePart *
mail_crypto_pgp_mime_part_decrypt (CamelMimePart *mime_part, CamelException *ex)
{
CamelPgpContext *context;
- CamelMimePart *part;
+ CamelMimePart *part = NULL;
context = camel_pgp_context_new (session, mail_config_get_pgp_type (),
mail_config_get_pgp_path ());
- part = camel_pgp_mime_part_decrypt (context, mime_part, ex);
- camel_object_unref (CAMEL_OBJECT (context));
+
+ if (context) {
+ part = camel_pgp_mime_part_decrypt (context, mime_part, ex);
+ camel_object_unref (CAMEL_OBJECT (context));
+ }
return part;
}