From: Richard Russon Date: Tue, 20 Aug 2019 11:48:34 +0000 (+0100) Subject: coverity: fix defects X-Git-Tag: 2019-10-25~93 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c54eaec70fdda94871b79911901882d55b20b091;p=neomutt coverity: fix defects --- diff --git a/ncrypt/crypt.c b/ncrypt/crypt.c index 83df4a562..27c3255fd 100644 --- a/ncrypt/crypt.c +++ b/ncrypt/crypt.c @@ -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 a2d5563a6..53124db2c 100644 --- 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)) {