diff options
82 files changed, 244 insertions, 511 deletions
diff --git a/apps/apps.c b/apps/apps.c index f2a17a4633..1b76dbf825 100644 --- a/apps/apps.c +++ b/apps/apps.c @@ -592,12 +592,9 @@ int load_cert_crl_http(const char *url, X509 **pcert, X509_CRL **pcrl) } err: - if (host) - OPENSSL_free(host); - if (path) - OPENSSL_free(path); - if (port) - OPENSSL_free(port); + OPENSSL_free(host); + OPENSSL_free(path); + OPENSSL_free(port); if (bio) BIO_free_all(bio); OCSP_REQ_CTX_free(rctx); @@ -660,8 +657,7 @@ X509 *load_cert(const char *file, int format, BIO_printf(bio_err, "unable to load certificate\n"); ERR_print_errors(bio_err); } - if (cert != NULL) - BIO_free(cert); + BIO_free(cert); return (x); } @@ -761,8 +757,7 @@ EVP_PKEY *load_key(const char *file, int format, int maybe_stdin, goto end; } end: - if (key != NULL) - BIO_free(key); + BIO_free(key); if (pkey == NULL) { BIO_printf(bio_err, "unable to load %s\n", key_descrip); ERR_print_errors(bio_err); @@ -849,8 +844,7 @@ EVP_PKEY *load_pubkey(const char *file, int format, int maybe_stdin, pkey = b2i_PublicKey_bio(key); #endif end: - if (key != NULL) - BIO_free(key); + BIO_free(key); if (pkey == NULL) BIO_printf(bio_err, "unable to load %s\n", key_descrip); return (pkey); diff --git a/apps/asn1pars.c b/apps/asn1pars.c index 01a50f4e5d..61bdeabe5b 100644 --- a/apps/asn1pars.c +++ b/apps/asn1pars.c @@ -319,15 +319,13 @@ int asn1parse_main(int argc, char **argv) BIO_free(b64); if (ret != 0) ERR_print_errors(bio_err); - if (buf != NULL) - BUF_MEM_free(buf); + BUF_MEM_free(buf); OPENSSL_free(name); OPENSSL_free(header); if (strictpem) OPENSSL_free(str); ASN1_TYPE_free(at); - if (osk != NULL) - sk_OPENSSL_STRING_free(osk); + sk_OPENSSL_STRING_free(osk); OBJ_cleanup(); return (ret); } @@ -514,10 +514,8 @@ end_of_options: errorline, configfile); goto end; } - if (tofree) { - OPENSSL_free(tofree); - tofree = NULL; - } + OPENSSL_free(tofree); + tofree = NULL; /* Lets get the config section we are using */ if (section == NULL) { @@ -1331,8 +1329,7 @@ end_of_options: /*****************************************************************/ ret = 0; end: - if (tofree) - OPENSSL_free(tofree); + OPENSSL_free(tofree); BIO_free_all(Cout); BIO_free_all(Sout); BIO_free_all(out); @@ -1342,13 +1339,12 @@ end_of_options: if (ret) ERR_print_errors(bio_err); app_RAND_write_file(randfile); - if (free_key && key) + if (free_key) OPENSSL_free(key); BN_free(serial); BN_free(crlnumber); free_index(db); - if (sigopts) - sk_OPENSSL_STRING_free(sigopts); + sk_OPENSSL_STRING_free(sigopts); EVP_PKEY_free(pkey); X509_free(x509); X509_CRL_free(crl); @@ -2000,8 +1996,7 @@ static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509, ok = 1; end: for (i = 0; i < DB_NUMBER; i++) - if (row[i] != NULL) - OPENSSL_free(row[i]); + OPENSSL_free(row[i]); X509_NAME_free(CAname); X509_NAME_free(subject); @@ -2159,10 +2154,8 @@ static int certify_spkac(X509 **xret, char *infile, EVP_PKEY *pkey, ext_copy, 0); end: X509_REQ_free(req); - if (parms != NULL) - CONF_free(parms); - if (spki != NULL) - NETSCAPE_SPKI_free(spki); + CONF_free(parms); + NETSCAPE_SPKI_free(spki); X509_NAME_ENTRY_free(ne); return (ok); diff --git a/apps/ciphers.c b/apps/ciphers.c index 3d84a2b14e..232fd602fd 100644 --- a/apps/ciphers.c +++ b/apps/ciphers.c @@ -214,7 +214,7 @@ int ciphers_main(int argc, char **argv) err: ERR_print_errors(bio_err); end: - if (use_supported && sk) + if (use_supported) sk_SSL_CIPHER_free(sk); SSL_CTX_free(ctx); SSL_free(ssl); diff --git a/apps/cms.c b/apps/cms.c index 25e3ad62fd..79d0b8f5d6 100644 --- a/apps/cms.c +++ b/apps/cms.c @@ -1117,20 +1117,15 @@ int cms_main(int argc, char **argv) sk_X509_pop_free(encerts, X509_free); sk_X509_pop_free(other, X509_free); X509_VERIFY_PARAM_free(vpm); - if (sksigners) - sk_OPENSSL_STRING_free(sksigners); - if (skkeys) - sk_OPENSSL_STRING_free(skkeys); + sk_OPENSSL_STRING_free(sksigners); + sk_OPENSSL_STRING_free(skkeys); OPENSSL_free(secret_key); OPENSSL_free(secret_keyid); OPENSSL_free(pwri_tmp); ASN1_OBJECT_free(econtent_type); - if (rr) - CMS_ReceiptRequest_free(rr); - if (rr_to) - sk_OPENSSL_STRING_free(rr_to); - if (rr_from) - sk_OPENSSL_STRING_free(rr_from); + CMS_ReceiptRequest_free(rr); + sk_OPENSSL_STRING_free(rr_to); + sk_OPENSSL_STRING_free(rr_from); for (key_param = key_first; key_param;) { cms_key_param *tparam; sk_OPENSSL_STRING_free(key_param->param); @@ -1247,8 +1242,7 @@ static void receipt_request_print(CMS_ContentInfo *cms) BIO_puts(bio_err, " Receipts To:\n"); gnames_stack_print(rto); } - if (rr) - CMS_ReceiptRequest_free(rr); + CMS_ReceiptRequest_free(rr); } } @@ -1280,12 +1274,9 @@ static STACK_OF(GENERAL_NAMES) *make_names_stack(STACK_OF(OPENSSL_STRING) *ns) return ret; err: - if (ret) - sk_GENERAL_NAMES_pop_free(ret, GENERAL_NAMES_free); - if (gens) - GENERAL_NAMES_free(gens); - if (gen) - GENERAL_NAME_free(gen); + sk_GENERAL_NAMES_pop_free(ret, GENERAL_NAMES_free); + GENERAL_NAMES_free(gens); + GENERAL_NAME_free(gen); return NULL; } diff --git a/apps/dgst.c b/apps/dgst.c index a679cb9fe8..5d23492779 100644 --- a/apps/dgst.c +++ b/apps/dgst.c @@ -443,14 +443,11 @@ int dgst_main(int argc, char **argv) end: OPENSSL_clear_free(buf, BUFSIZE); BIO_free(in); - if (passin) - OPENSSL_free(passin); + OPENSSL_free(passin); BIO_free_all(out); EVP_PKEY_free(sigkey); - if (sigopts) - sk_OPENSSL_STRING_free(sigopts); - if (macopts) - sk_OPENSSL_STRING_free(macopts); + sk_OPENSSL_STRING_free(sigopts); + sk_OPENSSL_STRING_free(macopts); OPENSSL_free(sigbuf); BIO_free(bmd); return (ret); diff --git a/apps/engine.c b/apps/engine.c index c7c0aafd75..832cb0afaa 100644 --- a/apps/engine.c +++ b/apps/engine.c @@ -261,8 +261,7 @@ static int util_verbose(ENGINE *e, int verbose, BIO *out, const char *indent) BIO_printf(out, "\n"); ret = 1; err: - if (cmds) - sk_OPENSSL_STRING_pop_free(cmds, identity); + sk_OPENSSL_STRING_pop_free(cmds, identity); OPENSSL_free(name); OPENSSL_free(desc); return ret; diff --git a/apps/genrsa.c b/apps/genrsa.c index a5ab658f96..e09e576c8b 100644 --- a/apps/genrsa.c +++ b/apps/genrsa.c @@ -198,10 +198,8 @@ int genrsa_main(int argc, char **argv) if (hexe && dece) { BIO_printf(bio_err, "e is %s (0x%s)\n", dece, hexe); } - if (hexe) - OPENSSL_free(hexe); - if (dece) - OPENSSL_free(dece); + OPENSSL_free(hexe); + OPENSSL_free(dece); { PW_CB_DATA cb_data; cb_data.password = passout; diff --git a/apps/ocsp.c b/apps/ocsp.c index d4ea019650..d4538a8600 100644 --- a/apps/ocsp.c +++ b/apps/ocsp.c @@ -917,8 +917,7 @@ static void make_ocsp_response(OCSP_RESPONSE **resp, OCSP_REQUEST *req, NULL); goto end; } - if (ca_id) - OCSP_CERTID_free(ca_id); + OCSP_CERTID_free(ca_id); ca_id = OCSP_cert_to_id(cert_id_md, NULL, ca); /* Is this request about our CA? */ diff --git a/apps/openssl.c b/apps/openssl.c index c6b048a90d..b71f3d19f5 100644 --- a/apps/openssl.c +++ b/apps/openssl.c @@ -511,12 +511,9 @@ int main(int argc, char *argv[]) end: OPENSSL_free(copied_argv); OPENSSL_free(to_free); - if (config != NULL) { - NCONF_free(config); - config = NULL; - } - if (prog != NULL) - lh_FUNCTION_free(prog); + NCONF_free(config); + config = NULL; + lh_FUNCTION_free(prog); OPENSSL_free(arg.argv); BIO_free(bio_in); diff --git a/apps/pkcs12.c b/apps/pkcs12.c index 4c62392e0b..0a4ee3ed10 100644 --- a/apps/pkcs12.c +++ b/apps/pkcs12.c @@ -554,8 +554,7 @@ int pkcs12_main(int argc, char **argv) app_RAND_write_file(NULL); BIO_free(in); BIO_free_all(out); - if (canames) - sk_OPENSSL_STRING_free(canames); + sk_OPENSSL_STRING_free(canames); OPENSSL_free(passin); OPENSSL_free(passout); return (ret); diff --git a/apps/req.c b/apps/req.c index e8e18ecdde..b9dc35cbf8 100644 --- a/apps/req.c +++ b/apps/req.c @@ -872,16 +872,14 @@ int req_main(int argc, char **argv) if (ret) { ERR_print_errors(bio_err); } - if ((req_conf != NULL) && (req_conf != config)) + if (req_conf != config) NCONF_free(req_conf); BIO_free(in); BIO_free_all(out); EVP_PKEY_free(pkey); EVP_PKEY_CTX_free(genctx); - if (pkeyopts) - sk_OPENSSL_STRING_free(pkeyopts); - if (sigopts) - sk_OPENSSL_STRING_free(sigopts); + sk_OPENSSL_STRING_free(pkeyopts); + sk_OPENSSL_STRING_free(sigopts); #ifndef OPENSSL_NO_ENGINE ENGINE_free(gen_eng); #endif diff --git a/apps/s_cb.c b/apps/s_cb.c index 1f2d371952..13a3a25652 100644 --- a/apps/s_cb.c +++ b/apps/s_cb.c @@ -1202,6 +1202,9 @@ static int ssl_excert_prepend(SSL_EXCERT **pexc) void ssl_excert_free(SSL_EXCERT *exc) { SSL_EXCERT *curr; + + if (!exc) + return; while (exc) { X509_free(exc->cert); EVP_PKEY_free(exc->key); @@ -1311,8 +1314,7 @@ int args_excert(int opt, SSL_EXCERT **pexc) err: ERR_print_errors(bio_err); - if (exc) - ssl_excert_free(exc); + ssl_excert_free(exc); *pexc = NULL; return 0; } |