]> granicus.if.org Git - neomutt/commitdiff
coverity: fix defects
authorRichard Russon <rich@flatcap.org>
Tue, 20 Aug 2019 11:48:34 +0000 (12:48 +0100)
committerRichard Russon <rich@flatcap.org>
Tue, 20 Aug 2019 11:48:54 +0000 (12:48 +0100)
ncrypt/crypt.c
send.c

index 83df4a562d06feef6bc5aa9c3cc11b45e64c1f5a..27c3255fd0d773bd1424bb05907f74821751ffb6 100644 (file)
@@ -193,7 +193,7 @@ int mutt_protect(struct Email *e, char *keylist, bool postpone)
   if (sign && !(security & SEC_AUTOCRYPT) && !crypt_valid_passphrase(security))
     return -1;
 
-  if ((WithCrypto & APPLICATION_PGP) && !(security & SEC_AUTOCRYPT) &&
+  if (((WithCrypto & APPLICATION_PGP) != 0) && !(security & SEC_AUTOCRYPT) &&
       ((security & PGP_INLINE) == PGP_INLINE))
   {
     if ((e->content->type != TYPE_TEXT) ||
diff --git a/send.c b/send.c
index a2d5563a6b4217ec9227b454d3ee1174f2c2f161..53124db2c87449939705473e168bb7fd581d9610 100644 (file)
--- a/send.c
+++ b/send.c
@@ -1607,7 +1607,7 @@ static int save_fcc(struct Email *e, char *fcc, size_t fcc_len, struct Body *cle
    * Protected Headers. */
   if (!C_FccBeforeSend)
   {
-    if (WithCrypto && (e->security & (SEC_ENCRYPT | SEC_SIGN | SEC_AUTOCRYPT)) && C_FccClear)
+    if ((WithCrypto != 0) && (e->security & (SEC_ENCRYPT | SEC_SIGN | SEC_AUTOCRYPT)) && C_FccClear)
     {
       e->content = clear_content;
       e->security &= ~(SEC_ENCRYPT | SEC_SIGN | SEC_AUTOCRYPT);
@@ -1754,7 +1754,7 @@ static int postpone_message(struct Email *e_post, struct Email *e_cur, char *fcc
 
   mutt_encode_descriptions(e_post->content, true);
 
-  if (WithCrypto && C_PostponeEncrypt && (e_post->security & (SEC_ENCRYPT | SEC_AUTOCRYPT)))
+  if ((WithCrypto != 0) && C_PostponeEncrypt && (e_post->security & (SEC_ENCRYPT | SEC_AUTOCRYPT)))
   {
     if (((WithCrypto & APPLICATION_PGP) != 0) && (e_post->security & APPLICATION_PGP))
       encrypt_as = C_PgpDefaultKey;
@@ -2268,7 +2268,7 @@ int ci_send_message(SendFlags flags, struct Email *e_templ, const char *tempfile
         e_templ->security |= SEC_SIGN;
       if (C_CryptReplysignencrypted && e_cur && (e_cur->security & SEC_ENCRYPT))
         e_templ->security |= SEC_SIGN;
-      if ((WithCrypto & APPLICATION_PGP) &&
+      if (((WithCrypto & APPLICATION_PGP) != 0) &&
           ((e_templ->security & (SEC_ENCRYPT | SEC_SIGN)) || C_CryptOpportunisticEncrypt))
       {
         if (C_PgpAutoinline)
@@ -2532,8 +2532,11 @@ int ci_send_message(SendFlags flags, struct Email *e_templ, const char *tempfile
       else if ((e_templ->security & (SEC_ENCRYPT | SEC_AUTOCRYPT)) ||
                ((e_templ->security & SEC_SIGN) && (e_templ->content->type == TYPE_APPLICATION)))
       {
-        mutt_body_free(&e_templ->content); /* destroy PGP data */
-        e_templ->content = clear_content;  /* restore clear text. */
+        if (e_templ->content != clear_content)
+        {
+          mutt_body_free(&e_templ->content); /* destroy PGP data */
+          e_templ->content = clear_content;  /* restore clear text. */
+        }
       }
       else if ((e_templ->security & SEC_SIGN) && (e_templ->content->type == TYPE_MULTIPART))
       {