aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/apps.c12
-rw-r--r--apps/asn1pars.c9
-rw-r--r--apps/ca.c3
-rw-r--r--apps/ciphers.c3
-rw-r--r--apps/crl2p7.c9
-rw-r--r--apps/dgst.c6
-rw-r--r--apps/dh.c6
-rw-r--r--apps/dhparam.c6
-rw-r--r--apps/dsa.c6
-rw-r--r--apps/dsaparam.c6
-rw-r--r--apps/ec.c6
-rw-r--r--apps/ecparam.c6
-rw-r--r--apps/enc.c15
-rw-r--r--apps/engine.c3
-rw-r--r--apps/errstr.c3
-rw-r--r--apps/gendh.c3
-rw-r--r--apps/gendsa.c6
-rw-r--r--apps/genpkey.c3
-rw-r--r--apps/genrsa.c3
-rw-r--r--apps/ocsp.c3
-rw-r--r--apps/openssl.c6
-rw-r--r--apps/passwd.c6
-rw-r--r--apps/pkcs7.c6
-rw-r--r--apps/rand.c3
-rw-r--r--apps/rsa.c3
-rw-r--r--apps/s_client.c12
-rw-r--r--apps/s_server.c25
-rw-r--r--apps/sess_id.c6
-rw-r--r--apps/ts.c2
-rw-r--r--crypto/asn1/asn_mime.c3
-rw-r--r--crypto/asn1/bio_asn1.c4
-rw-r--r--crypto/asn1/bio_ndef.c3
-rw-r--r--crypto/bio/bio_lib.c3
-rw-r--r--crypto/bio/bss_acpt.c12
-rw-r--r--crypto/bio/bss_bio.c12
-rw-r--r--crypto/bio/bss_conn.c6
-rw-r--r--crypto/cms/cms_lib.c3
-rw-r--r--crypto/cms/cms_sd.c3
-rw-r--r--crypto/cms/cms_smime.c8
-rw-r--r--crypto/dsa/dsatest.c6
-rw-r--r--crypto/ecdsa/ecdsatest.c3
-rw-r--r--crypto/ocsp/ocsp_ht.c3
-rw-r--r--crypto/pkcs7/pk7_doit.c29
-rw-r--r--crypto/srp/srp_vfy.c3
-rw-r--r--crypto/threads/mttest.c14
-rw-r--r--crypto/x509/by_file.c6
-rw-r--r--demos/b64.c12
-rw-r--r--demos/bio/saccept.c6
-rw-r--r--demos/bio/server-arg.c3
-rw-r--r--demos/bio/server-conf.c3
-rw-r--r--demos/cms/cms_comp.c6
-rw-r--r--demos/cms/cms_ddec.c12
-rw-r--r--demos/cms/cms_dec.c9
-rw-r--r--demos/cms/cms_denc.c12
-rw-r--r--demos/cms/cms_enc.c9
-rw-r--r--demos/cms/cms_sign.c9
-rw-r--r--demos/cms/cms_sign2.c9
-rw-r--r--demos/cms/cms_uncomp.c6
-rw-r--r--demos/cms/cms_ver.c9
-rw-r--r--demos/smime/smdec.c9
-rw-r--r--demos/smime/smenc.c9
-rw-r--r--demos/smime/smsign.c9
-rw-r--r--demos/smime/smsign2.c9
-rw-r--r--demos/smime/smver.c9
-rw-r--r--doc/crypto/BIO_new.pod5
-rw-r--r--engines/e_chil.c9
-rw-r--r--engines/e_sureware.c9
-rw-r--r--ssl/bio_ssl.c9
-rw-r--r--ssl/s3_enc.c3
-rw-r--r--ssl/s3_lib.c10
-rw-r--r--ssl/ssl_cert.c6
-rw-r--r--ssl/ssl_conf.c3
-rw-r--r--ssl/ssl_lib.c9
-rw-r--r--ssl/ssl_rsa.c24
-rw-r--r--ssl/ssl_task.c12
-rw-r--r--ssl/ssltest.c36
76 files changed, 202 insertions, 390 deletions
diff --git a/apps/apps.c b/apps/apps.c
index 233d382cd5..1dcaabf87d 100644
--- a/apps/apps.c
+++ b/apps/apps.c
@@ -1114,8 +1114,7 @@ EVP_PKEY *load_pubkey(BIO *err, 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(err, "unable to load %s\n", key_descrip);
return (pkey);
@@ -1682,8 +1681,7 @@ BIGNUM *load_serial(char *serialfile, int create, ASN1_INTEGER **retai)
ai = NULL;
}
err:
- if (in != NULL)
- BIO_free(in);
+ BIO_free(in);
if (ai != NULL)
ASN1_INTEGER_free(ai);
return (ret);
@@ -1741,8 +1739,7 @@ int save_serial(char *serialfile, char *suffix, BIGNUM *serial,
ai = NULL;
}
err:
- if (out != NULL)
- BIO_free_all(out);
+ BIO_free_all(out);
if (ai != NULL)
ASN1_INTEGER_free(ai);
return (ret);
@@ -1896,8 +1893,7 @@ CA_DB *load_index(char *dbfile, DB_ATTR *db_attr)
NCONF_free(dbattr_conf);
if (tmpdb)
TXT_DB_free(tmpdb);
- if (in)
- BIO_free_all(in);
+ BIO_free_all(in);
return retdb;
}
diff --git a/apps/asn1pars.c b/apps/asn1pars.c
index da950115e3..1576f1cc05 100644
--- a/apps/asn1pars.c
+++ b/apps/asn1pars.c
@@ -370,12 +370,9 @@ int MAIN(int argc, char **argv)
ret = 0;
end:
BIO_free(derout);
- if (in != NULL)
- BIO_free(in);
- if (out != NULL)
- BIO_free_all(out);
- if (b64 != NULL)
- BIO_free(b64);
+ BIO_free(in);
+ BIO_free_all(out);
+ BIO_free(b64);
if (ret != 0)
ERR_print_errors(bio_err);
if (buf != NULL)
diff --git a/apps/ca.c b/apps/ca.c
index b498b0a25a..89bece8ed1 100644
--- a/apps/ca.c
+++ b/apps/ca.c
@@ -1566,8 +1566,7 @@ static int certify(X509 **xret, char *infile, EVP_PKEY *pkey, X509 *x509,
err:
if (req != NULL)
X509_REQ_free(req);
- if (in != NULL)
- BIO_free(in);
+ BIO_free(in);
return (ok);
}
diff --git a/apps/ciphers.c b/apps/ciphers.c
index 803b021f5c..6c7ff01eea 100644
--- a/apps/ciphers.c
+++ b/apps/ciphers.c
@@ -227,8 +227,7 @@ int MAIN(int argc, char **argv)
SSL_CTX_free(ctx);
if (ssl != NULL)
SSL_free(ssl);
- if (STDout != NULL)
- BIO_free_all(STDout);
+ BIO_free_all(STDout);
apps_shutdown();
OPENSSL_EXIT(ret);
}
diff --git a/apps/crl2p7.c b/apps/crl2p7.c
index 0763817e61..ab0c3d6d28 100644
--- a/apps/crl2p7.c
+++ b/apps/crl2p7.c
@@ -268,10 +268,8 @@ int MAIN(int argc, char **argv)
}
ret = 0;
end:
- if (in != NULL)
- BIO_free(in);
- if (out != NULL)
- BIO_free_all(out);
+ BIO_free(in);
+ BIO_free_all(out);
if (p7 != NULL)
PKCS7_free(p7);
if (crl != NULL)
@@ -326,8 +324,7 @@ static int add_certs_from_file(STACK_OF(X509) *stack, char *certfile)
ret = count;
end:
/* never need to OPENSSL_free x */
- if (in != NULL)
- BIO_free(in);
+ BIO_free(in);
if (sk != NULL)
sk_X509_INFO_free(sk);
return (ret);
diff --git a/apps/dgst.c b/apps/dgst.c
index 95e5fa3fc7..ac3b583793 100644
--- a/apps/dgst.c
+++ b/apps/dgst.c
@@ -518,8 +518,7 @@ int MAIN(int argc, char **argv)
OPENSSL_cleanse(buf, BUFSIZE);
OPENSSL_free(buf);
}
- if (in != NULL)
- BIO_free(in);
+ BIO_free(in);
if (passin)
OPENSSL_free(passin);
BIO_free_all(out);
@@ -530,8 +529,7 @@ int MAIN(int argc, char **argv)
sk_OPENSSL_STRING_free(macopts);
if (sigbuf)
OPENSSL_free(sigbuf);
- if (bmd != NULL)
- BIO_free(bmd);
+ BIO_free(bmd);
apps_shutdown();
OPENSSL_EXIT(err);
}
diff --git a/apps/dh.c b/apps/dh.c
index a9216336e5..1b653f548a 100644
--- a/apps/dh.c
+++ b/apps/dh.c
@@ -310,10 +310,8 @@ int MAIN(int argc, char **argv)
}
ret = 0;
end:
- if (in != NULL)
- BIO_free(in);
- if (out != NULL)
- BIO_free_all(out);
+ BIO_free(in);
+ BIO_free_all(out);
DH_free(dh);
apps_shutdown();
OPENSSL_EXIT(ret);
diff --git a/apps/dhparam.c b/apps/dhparam.c
index 12a2be6455..fc5962a7a1 100644
--- a/apps/dhparam.c
+++ b/apps/dhparam.c
@@ -515,10 +515,8 @@ int MAIN(int argc, char **argv)
}
ret = 0;
end:
- if (in != NULL)
- BIO_free(in);
- if (out != NULL)
- BIO_free_all(out);
+ BIO_free(in);
+ BIO_free_all(out);
DH_free(dh);
apps_shutdown();
OPENSSL_EXIT(ret);
diff --git a/apps/dsa.c b/apps/dsa.c
index 8d085bcef2..1ea0d7346d 100644
--- a/apps/dsa.c
+++ b/apps/dsa.c
@@ -356,10 +356,8 @@ int MAIN(int argc, char **argv)
} else
ret = 0;
end:
- if (in != NULL)
- BIO_free(in);
- if (out != NULL)
- BIO_free_all(out);
+ BIO_free(in);
+ BIO_free_all(out);
DSA_free(dsa);
if (passin)
OPENSSL_free(passin);
diff --git a/apps/dsaparam.c b/apps/dsaparam.c
index fc1c817604..f63ecb28ec 100644
--- a/apps/dsaparam.c
+++ b/apps/dsaparam.c
@@ -434,10 +434,8 @@ int MAIN(int argc, char **argv)
end:
if (cb != NULL)
BN_GENCB_free(cb);
- if (in != NULL)
- BIO_free(in);
- if (out != NULL)
- BIO_free_all(out);
+ BIO_free(in);
+ BIO_free_all(out);
DSA_free(dsa);
apps_shutdown();
OPENSSL_EXIT(ret);
diff --git a/apps/ec.c b/apps/ec.c
index b04dadaf18..2064723eb1 100644
--- a/apps/ec.c
+++ b/apps/ec.c
@@ -343,10 +343,8 @@ int MAIN(int argc, char **argv)
} else
ret = 0;
end:
- if (in)
- BIO_free(in);
- if (out)
- BIO_free_all(out);
+ BIO_free(in);
+ BIO_free_all(out);
if (eckey)
EC_KEY_free(eckey);
if (passin)
diff --git a/apps/ecparam.c b/apps/ecparam.c
index 06ac77b838..d4177474d5 100644
--- a/apps/ecparam.c
+++ b/apps/ecparam.c
@@ -621,10 +621,8 @@ int MAIN(int argc, char **argv)
BN_free(ec_cofactor);
if (buffer)
OPENSSL_free(buffer);
- if (in != NULL)
- BIO_free(in);
- if (out != NULL)
- BIO_free_all(out);
+ BIO_free(in);
+ BIO_free_all(out);
if (group != NULL)
EC_GROUP_free(group);
apps_shutdown();
diff --git a/apps/enc.c b/apps/enc.c
index 1739b7ec23..b95a6a2031 100644
--- a/apps/enc.c
+++ b/apps/enc.c
@@ -657,17 +657,12 @@ int MAIN(int argc, char **argv)
OPENSSL_free(strbuf);
if (buff != NULL)
OPENSSL_free(buff);
- if (in != NULL)
- BIO_free(in);
- if (out != NULL)
- BIO_free_all(out);
- if (benc != NULL)
- BIO_free(benc);
- if (b64 != NULL)
- BIO_free(b64);
+ BIO_free(in);
+ BIO_free_all(out);
+ BIO_free(benc);
+ BIO_free(b64);
#ifdef ZLIB
- if (bzl != NULL)
- BIO_free(bzl);
+ BIO_free(bzl);
#endif
if (pass)
OPENSSL_free(pass);
diff --git a/apps/engine.c b/apps/engine.c
index 8a1e746ab6..53864650ac 100644
--- a/apps/engine.c
+++ b/apps/engine.c
@@ -497,8 +497,7 @@ int MAIN(int argc, char **argv)
sk_OPENSSL_STRING_pop_free(engines, identity);
sk_OPENSSL_STRING_pop_free(pre_cmds, identity);
sk_OPENSSL_STRING_pop_free(post_cmds, identity);
- if (bio_out != NULL)
- BIO_free_all(bio_out);
+ BIO_free_all(bio_out);
apps_shutdown();
OPENSSL_EXIT(ret);
}
diff --git a/apps/errstr.c b/apps/errstr.c
index c2d4fdec35..668c5f3024 100644
--- a/apps/errstr.c
+++ b/apps/errstr.c
@@ -100,8 +100,7 @@ int MAIN(int argc, char **argv)
lh_ERR_STRING_DATA_node_usage_stats_bio(ERR_get_string_table(),
out);
}
- if (out != NULL)
- BIO_free_all(out);
+ BIO_free_all(out);
argc--;
argv++;
}
diff --git a/apps/gendh.c b/apps/gendh.c
index 6102b79511..904bcf3a94 100644
--- a/apps/gendh.c
+++ b/apps/gendh.c
@@ -210,8 +210,7 @@ int MAIN(int argc, char **argv)
end:
if (ret != 0)
ERR_print_errors(bio_err);
- if (out != NULL)
- BIO_free_all(out);
+ BIO_free_all(out);
DH_free(dh);
if (cb != NULL)
BN_GENCB_free(cb);
diff --git a/apps/gendsa.c b/apps/gendsa.c
index d330a01002..8288eb90ab 100644
--- a/apps/gendsa.c
+++ b/apps/gendsa.c
@@ -267,10 +267,8 @@ int MAIN(int argc, char **argv)
end:
if (ret != 0)
ERR_print_errors(bio_err);
- if (in != NULL)
- BIO_free(in);
- if (out != NULL)
- BIO_free_all(out);
+ BIO_free(in);
+ BIO_free_all(out);
DSA_free(dsa);
if (passout)
OPENSSL_free(passout);
diff --git a/apps/genpkey.c b/apps/genpkey.c
index fc19a928c3..5b7f4335b1 100644
--- a/apps/genpkey.c
+++ b/apps/genpkey.c
@@ -272,8 +272,7 @@ int MAIN(int argc, char **argv)
EVP_PKEY_free(pkey);
if (ctx)
EVP_PKEY_CTX_free(ctx);
- if (out)
- BIO_free_all(out);
+ BIO_free_all(out);
BIO_free(in);
if (pass)
OPENSSL_free(pass);
diff --git a/apps/genrsa.c b/apps/genrsa.c
index 1b06c82e40..cf60219642 100644
--- a/apps/genrsa.c
+++ b/apps/genrsa.c
@@ -312,8 +312,7 @@ int MAIN(int argc, char **argv)
if (cb)
BN_GENCB_free(cb);
RSA_free(rsa);
- if (out)
- BIO_free_all(out);
+ BIO_free_all(out);
if (passout)
OPENSSL_free(passout);
if (ret != 0)
diff --git a/apps/ocsp.c b/apps/ocsp.c
index 83a71752b1..95380964a3 100644
--- a/apps/ocsp.c
+++ b/apps/ocsp.c
@@ -1362,8 +1362,7 @@ OCSP_RESPONSE *process_responder(BIO *err, OCSP_REQUEST *req,
if (!resp)
BIO_printf(bio_err, "Error querying OCSP responder\n");
end:
- if (cbio)
- BIO_free_all(cbio);
+ BIO_free_all(cbio);
if (ctx)
SSL_CTX_free(ctx);
return resp;
diff --git a/apps/openssl.c b/apps/openssl.c
index e070a444a5..e93aed702a 100644
--- a/apps/openssl.c
+++ b/apps/openssl.c
@@ -431,10 +431,8 @@ int main(int Argc, char *ARGV[])
#endif
apps_shutdown();
CRYPTO_mem_leaks(bio_err);
- if (bio_err != NULL) {
- BIO_free(bio_err);
- bio_err = NULL;
- }
+ BIO_free(bio_err);
+ bio_err = NULL;
OPENSSL_EXIT(ret);
}
diff --git a/apps/passwd.c b/apps/passwd.c
index 798a6d5936..2814b32c75 100644
--- a/apps/passwd.c
+++ b/apps/passwd.c
@@ -273,10 +273,8 @@ int MAIN(int argc, char **argv)
OPENSSL_free(salt_malloc);
if (passwd_malloc)
OPENSSL_free(passwd_malloc);
- if (in)
- BIO_free(in);
- if (out)
- BIO_free_all(out);
+ BIO_free(in);
+ BIO_free_all(out);
apps_shutdown();
OPENSSL_EXIT(ret);
}
diff --git a/apps/pkcs7.c b/apps/pkcs7.c
index 643507f216..1b07c022a4 100644
--- a/apps/pkcs7.c
+++ b/apps/pkcs7.c
@@ -299,10 +299,8 @@ int MAIN(int argc, char **argv)
end:
if (p7 != NULL)
PKCS7_free(p7);
- if (in != NULL)
- BIO_free(in);
- if (out != NULL)
- BIO_free_all(out);
+ BIO_free(in);
+ BIO_free_all(out);
apps_shutdown();
OPENSSL_EXIT(ret);
}
diff --git a/apps/rand.c b/apps/rand.c
index e159da37be..45f16b9094 100644
--- a/apps/rand.c
+++ b/apps/rand.c
@@ -222,8 +222,7 @@ int MAIN(int argc, char **argv)
err:
ERR_print_errors(bio_err);
- if (out)
- BIO_free_all(out);
+ BIO_free_all(out);
apps_shutdown();
OPENSSL_EXIT(ret);
}
diff --git a/apps/rsa.c b/apps/rsa.c
index ac4a3c43ef..2f3f871a33 100644
--- a/apps/rsa.c
+++ b/apps/rsa.c
@@ -422,8 +422,7 @@ int MAIN(int argc, char **argv)
} else
ret = 0;
end:
- if (out != NULL)
- BIO_free_all(out);
+ BIO_free_all(out);
RSA_free(rsa);
if (passin)
OPENSSL_free(passin);
diff --git a/apps/s_client.c b/apps/s_client.c
index cdea32280c..08749830ba 100644
--- a/apps/s_client.c
+++ b/apps/s_client.c
@@ -2059,14 +2059,10 @@ int MAIN(int argc, char **argv)
OPENSSL_cleanse(mbuf, BUFSIZZ);
OPENSSL_free(mbuf);
}
- if (bio_c_out != NULL) {
- BIO_free(bio_c_out);
- bio_c_out = NULL;
- }
- if (bio_c_msg != NULL) {
- BIO_free(bio_c_msg);
- bio_c_msg = NULL;
- }
+ BIO_free(bio_c_out);
+ bio_c_out = NULL;
+ BIO_free(bio_c_msg);
+ bio_c_msg = NULL;
apps_shutdown();
OPENSSL_EXIT(ret);
}
diff --git a/apps/s_server.c b/apps/s_server.c
index c3884d26ab..37c40cb2fb 100644
--- a/apps/s_server.c
+++ b/apps/s_server.c
@@ -2039,8 +2039,7 @@ int MAIN(int argc, char *argv[])
X509_free(s_cert2);
if (s_key2)
EVP_PKEY_free(s_key2);
- if (serverinfo_in != NULL)
- BIO_free(serverinfo_in);
+ BIO_free(serverinfo_in);
# ifndef OPENSSL_NO_NEXTPROTONEG
if (next_proto.data)
OPENSSL_free(next_proto.data);
@@ -2057,14 +2056,10 @@ int MAIN(int argc, char *argv[])
if (jpake_secret && psk_key)
OPENSSL_free(psk_key);
#endif
- if (bio_s_out != NULL) {
- BIO_free(bio_s_out);
- bio_s_out = NULL;
- }
- if (bio_s_msg != NULL) {
- BIO_free(bio_s_msg);
- bio_s_msg = NULL;
- }
+ BIO_free(bio_s_out);
+ bio_s_out = NULL;
+ BIO_free(bio_s_msg);
+ bio_s_msg = NULL;
apps_shutdown();
OPENSSL_EXIT(ret);
}
@@ -2661,8 +2656,7 @@ static DH *load_dh_param(const char *dhfile)
goto err;
ret = PEM_read_bio_DHparams(bio, NULL, NULL, NULL);
err:
- if (bio != NULL)
- BIO_free(bio);
+ BIO_free(bio);
return (ret);
}
#endif
@@ -3021,9 +3015,7 @@ static int www_body(char *hostname, int s, int stype, unsigned char *context)
if (buf != NULL)
OPENSSL_free(buf);
- if (io != NULL)
- BIO_free_all(io);
-/* if (ssl_bio != NULL) BIO_free(ssl_bio);*/
+ BIO_free_all(io);
return (ret);
}
@@ -3159,8 +3151,7 @@ static int rev_body(char *hostname, int s, int stype, unsigned char *context)
if (buf != NULL)
OPENSSL_free(buf);
- if (io != NULL)
- BIO_free_all(io);
+ BIO_free_all(io);
return (ret);
}
diff --git a/apps/sess_id.c b/apps/sess_id.c
index 9400af964e..53ccbb3576 100644
--- a/apps/sess_id.c
+++ b/apps/sess_id.c
@@ -237,8 +237,7 @@ int MAIN(int argc, char **argv)
}
ret = 0;
end:
- if (out != NULL)
- BIO_free_all(out);
+ BIO_free_all(out);
if (x != NULL)
SSL_SESSION_free(x);
apps_shutdown();
@@ -279,7 +278,6 @@ static SSL_SESSION *load_sess_id(char *infile, int format)
}
end:
- if (in != NULL)
- BIO_free(in);
+ BIO_free(in);
return (x);
}
diff --git a/apps/ts.c b/apps/ts.c
index fb77d6a594..4c32ada410 100644
--- a/apps/ts.c
+++ b/apps/ts.c
@@ -162,8 +162,8 @@ int MAIN(int argc, char **argv)
apps_startup();
if (bio_err == NULL && (bio_err = BIO_new(BIO_s_file())) != NULL) {
- free_bio_err = 1;
BIO_set_fp(bio_err, stderr, BIO_NOCLOSE | BIO_FP_TEXT);
+ free_bio_err = 1;
}
if (!load_config(bio_err, NULL))
diff --git a/crypto/asn1/asn_mime.c b/crypto/asn1/asn_mime.c
index e96fb02094..e810345579 100644
--- a/crypto/asn1/asn_mime.c
+++ b/crypto/asn1/asn_mime.c
@@ -650,8 +650,7 @@ static int multi_split(BIO *bio, char *bound, STACK_OF(BIO) **ret)
BIO_write(bpart, linebuf, len);
}
}
- if (bpart != NULL)
- BIO_free(bpart);
+ BIO_free(bpart);
return 0;
}
diff --git a/crypto/asn1/bio_asn1.c b/crypto/asn1/bio_asn1.c
index 0b4fd1dd9e..d4be23c190 100644
--- a/crypto/asn1/bio_asn1.c
+++ b/crypto/asn1/bio_asn1.c
@@ -179,8 +179,8 @@ static int asn1_bio_init(BIO_ASN1_BUF_CTX *ctx, int size)
static int asn1_bio_free(BIO *b)
{
- BIO_ASN1_BUF_CTX *ctx;
- ctx = (BIO_ASN1_BUF_CTX *)b->ptr;
+ BIO_ASN1_BUF_CTX *ctx = (BIO_ASN1_BUF_CTX *)b->ptr;
+
if (ctx == NULL)
return 0;
if (ctx->buf)
diff --git a/crypto/asn1/bio_ndef.c b/crypto/asn1/bio_ndef.c
index 4a73ca9eac..1018787a63 100644
--- a/crypto/asn1/bio_ndef.c
+++ b/crypto/asn1/bio_ndef.c
@@ -142,8 +142,7 @@ BIO *BIO_new_NDEF(BIO *out, ASN1_VALUE *val, const ASN1_ITEM *it)
return sarg.ndef_bio;
err:
- if (asn_bio)
- BIO_free(asn_bio);
+ BIO_free(asn_bio);
if (ndef_aux)
OPENSSL_free(ndef_aux);
return NULL;
diff --git a/crypto/bio/bio_lib.c b/crypto/bio/bio_lib.c
index 11e0142de8..a5d8680d48 100644
--- a/crypto/bio/bio_lib.c
+++ b/crypto/bio/bio_lib.c
@@ -549,8 +549,7 @@ BIO *BIO_dup_chain(BIO *in)
}
return (ret);
err:
- if (ret != NULL)
- BIO_free(ret);
+ BIO_free(ret);
return (NULL);
}
diff --git a/crypto/bio/bss_acpt.c b/crypto/bio/bss_acpt.c
index 5aa06cf167..72f7bd21de 100644
--- a/crypto/bio/bss_acpt.c
+++ b/crypto/bio/bss_acpt.c
@@ -155,8 +155,7 @@ static void BIO_ACCEPT_free(BIO_ACCEPT *a)
OPENSSL_free(a->param_addr);
if (a->addr != NULL)
OPENSSL_free(a->addr);
- if (a->bio_chain != NULL)
- BIO_free(a->bio_chain);
+ BIO_free(a->bio_chain);
OPENSSL_free(a);
}
@@ -360,8 +359,7 @@ static long acpt_ctrl(BIO *b, int cmd, long num, void *ptr)
} else if (num == 1) {
data->accept_nbio = (ptr != NULL);
} else if (num == 2) {
- if (data->bio_chain != NULL)
- BIO_free(data->bio_chain);
+ BIO_free(data->bio_chain);
data->bio_chain = (BIO *)ptr;
}
}
@@ -448,10 +446,8 @@ BIO *BIO_new_accept(const char *str)
return (NULL);
if (BIO_set_accept_port(ret, str))
return (ret);
- else {
- BIO_free(ret);
- return (NULL);
- }
+ BIO_free(ret);
+ return (NULL);
}
#endif
diff --git a/crypto/bio/bss_bio.c b/crypto/bio/bss_bio.c
index d629a37a5a..c6bb3d6885 100644
--- a/crypto/bio/bss_bio.c
+++ b/crypto/bio/bss_bio.c
@@ -788,14 +788,10 @@ int BIO_new_bio_pair(BIO **bio1_p, size_t writebuf1,
err:
if (ret == 0) {
- if (bio1) {
- BIO_free(bio1);
- bio1 = NULL;
- }
- if (bio2) {
- BIO_free(bio2);
- bio2 = NULL;
- }
+ BIO_free(bio1);
+ bio1 = NULL;
+ BIO_free(bio2);
+ bio2 = NULL;
}
*bio1_p = bio1;
diff --git a/crypto/bio/bss_conn.c b/crypto/bio/bss_conn.c
index c7f57f1c7c..e95b4b38d6 100644
--- a/crypto/bio/bss_conn.c
+++ b/crypto/bio/bss_conn.c
@@ -588,10 +588,8 @@ BIO *BIO_new_connect(const char *str)
return (NULL);
if (BIO_set_conn_hostname(ret, str))
return (ret);
- else {
- BIO_free(ret);
- return (NULL);
- }
+ BIO_free(ret);
+ return (NULL);
}
#endif
diff --git a/crypto/cms/cms_lib.c b/crypto/cms/cms_lib.c
index 7e1c1e8d94..6d2a0e8275 100644
--- a/crypto/cms/cms_lib.c
+++ b/crypto/cms/cms_lib.c
@@ -354,8 +354,7 @@ BIO *cms_DigestAlgorithm_init_bio(X509_ALGOR *digestAlgorithm)
}
return mdbio;
err:
- if (mdbio)
- BIO_free(mdbio);
+ BIO_free(mdbio);
return NULL;
}
diff --git a/crypto/cms/cms_sd.c b/crypto/cms/cms_sd.c
index b8ed1a1bea..c45d30eac1 100644
--- a/crypto/cms/cms_sd.c
+++ b/crypto/cms/cms_sd.c
@@ -806,8 +806,7 @@ BIO *cms_SignedData_init_bio(CMS_ContentInfo *cms)
}
return chain;
err:
- if (chain)
- BIO_free_all(chain);
+ BIO_free_all(chain);
return NULL;
}
diff --git a/crypto/cms/cms_smime.c b/crypto/cms/cms_smime.c
index 6f6f20d63a..f491ec9e77 100644
--- a/crypto/cms/cms_smime.c
+++ b/crypto/cms/cms_smime.c
@@ -114,7 +114,7 @@ static int cms_copy_content(BIO *out, BIO *in, unsigned int flags)
r = 1;
err:
- if (tmpout && (tmpout != out))
+ if (tmpout != out)
BIO_free(tmpout);
return r;
@@ -446,14 +446,13 @@ int CMS_verify(CMS_ContentInfo *cms, STACK_OF(X509) *certs,
if (tmpin != dcont)
BIO_free(tmpin);
} else {
-
if (dcont && (tmpin == dcont))
do_free_upto(cmsbio, dcont);
else
BIO_free_all(cmsbio);
}
- if (tmpout && out != tmpout)
+ if (out != tmpout)
BIO_free_all(tmpout);
if (cms_certs)
@@ -580,8 +579,7 @@ CMS_ContentInfo *CMS_sign_receipt(CMS_SignerInfo *si,
r = 1;
err:
- if (rct_cont)
- BIO_free(rct_cont);
+ BIO_free(rct_cont);
if (r)
return cms;
CMS_ContentInfo_free(cms);
diff --git a/crypto/dsa/dsatest.c b/crypto/dsa/dsatest.c
index bf47816037..a5d40f1eb6 100644
--- a/crypto/dsa/dsatest.c
+++ b/crypto/dsa/dsatest.c
@@ -218,10 +218,8 @@ int main(int argc, char **argv)
ERR_remove_thread_state(NULL);
ERR_free_strings();
CRYPTO_mem_leaks(bio_err);
- if (bio_err != NULL) {
- BIO_free(bio_err);
- bio_err = NULL;
- }
+ BIO_free(bio_err);
+ bio_err = NULL;
# ifdef OPENSSL_SYS_NETWARE
if (!ret)
printf("ERROR\n");
diff --git a/crypto/ecdsa/ecdsatest.c b/crypto/ecdsa/ecdsatest.c
index c2132da882..346ccd053f 100644
--- a/crypto/ecdsa/ecdsatest.c
+++ b/crypto/ecdsa/ecdsatest.c
@@ -563,8 +563,7 @@ int main(void)
ERR_remove_thread_state(NULL);
ERR_free_strings();
CRYPTO_mem_leaks(out);
- if (out != NULL)
- BIO_free(out);
+ BIO_free(out);
return ret;
}
#endif
diff --git a/crypto/ocsp/ocsp_ht.c b/crypto/ocsp/ocsp_ht.c
index aca0d48879..4a06a8e1ef 100644
--- a/crypto/ocsp/ocsp_ht.c
+++ b/crypto/ocsp/ocsp_ht.c
@@ -136,8 +136,7 @@ OCSP_REQ_CTX *OCSP_REQ_CTX_new(BIO *io, int maxline)
void OCSP_REQ_CTX_free(OCSP_REQ_CTX *rctx)
{
- if (rctx->mem)
- BIO_free(rctx->mem);
+ BIO_free(rctx->mem);
if (rctx->iobuf)
OPENSSL_free(rctx->iobuf);
OPENSSL_free(rctx);
diff --git a/crypto/pkcs7/pk7_doit.c b/crypto/pkcs7/pk7_doit.c
index f77326b883..b7c66a3160 100644
--- a/crypto/pkcs7/pk7_doit.c
+++ b/crypto/pkcs7/pk7_doit.c
@@ -128,8 +128,7 @@ static int PKCS7_bio_add_digest(BIO **pbio, X509_ALGOR *alg)
return 1;
err:
- if (btmp)
- BIO_free(btmp);
+ BIO_free(btmp);
return 0;
}
@@ -390,16 +389,12 @@ BIO *PKCS7_dataInit(PKCS7 *p7, BIO *bio)
BIO_push(out, bio);
else
out = bio;
- bio = NULL;
- if (0) {
+ return out;
+
err:
- if (out != NULL)
- BIO_free_all(out);
- if (btmp != NULL)
- BIO_free_all(btmp);
- out = NULL;
- }
- return (out);
+ BIO_free_all(out);
+ BIO_free_all(btmp);
+ return NULL;
}
static int pkcs7_cmp_ri(PKCS7_RECIP_INFO *ri, X509 *pcert)
@@ -637,14 +632,10 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert)
OPENSSL_cleanse(tkey, tkeylen);
OPENSSL_free(tkey);
}
- if (out != NULL)
- BIO_free_all(out);
- if (btmp != NULL)
- BIO_free_all(btmp);
- if (etmp != NULL)
- BIO_free_all(etmp);
- if (bio != NULL)
- BIO_free_all(bio);
+ BIO_free_all(out);
+ BIO_free_all(btmp);
+ BIO_free_all(etmp);
+ BIO_free_all(bio);
out = NULL;
}
return (out);
diff --git a/crypto/srp/srp_vfy.c b/crypto/srp/srp_vfy.c
index 9d83a8f606..82b9a77b14 100644
--- a/crypto/srp/srp_vfy.c
+++ b/crypto/srp/srp_vfy.c
@@ -460,8 +460,7 @@ int SRP_VBASE_init(SRP_VBASE *vb, char *verifier_file)
if (tmpdb)
TXT_DB_free(tmpdb);
- if (in)
- BIO_free_all(in);
+ BIO_free_all(in);
sk_SRP_gN_free(SRP_gN_tab);
diff --git a/crypto/threads/mttest.c b/crypto/threads/mttest.c
index ea3784c72f..f6f8df289c 100644
--- a/crypto/threads/mttest.c
+++ b/crypto/threads/mttest.c
@@ -612,15 +612,11 @@ int doit(char *ctx[4])
}
/* The SSL's are optionally freed in the following calls */
- if (c_to_s != NULL)
- BIO_free(c_to_s);
- if (s_to_c != NULL)
- BIO_free(s_to_c);
-
- if (c_bio != NULL)
- BIO_free(c_bio);
- if (s_bio != NULL)
- BIO_free(s_bio);
+ BIO_free(c_to_s);
+ BIO_free(s_to_c);
+
+ BIO_free(c_bio);
+ BIO_free(s_bio);
return (0);
}
diff --git a/crypto/x509/by_file.c b/crypto/x509/by_file.c
index 43a073003d..bc1c90cc64 100644
--- a/crypto/x509/by_file.c
+++ b/crypto/x509/by_file.c
@@ -176,8 +176,7 @@ int X509_load_cert_file(X509_LOOKUP *ctx, const char *file, int type)
err:
if (x != NULL)
X509_free(x);
- if (in != NULL)
- BIO_free(in);
+ BIO_free(in);
return (ret);
}
@@ -235,8 +234,7 @@ int X509_load_crl_file(X509_LOOKUP *ctx, const char *file, int type)
err:
if (x != NULL)
X509_CRL_free(x);
- if (in != NULL)
- BIO_free(in);
+ BIO_free(in);
return (ret);
}
diff --git a/demos/b64.c b/demos/b64.c
index d8ed2a6a04..fcc69562c1 100644
--- a/demos/b64.c
+++ b/demos/b64.c
@@ -243,13 +243,9 @@ char **argv;
OPENSSL_free(strbuf);
if (buff != NULL)
OPENSSL_free(buff);
- if (in != NULL)
- BIO_free(in);
- if (out != NULL)
- BIO_free(out);
- if (benc != NULL)
- BIO_free(benc);
- if (b64 != NULL)
- BIO_free(b64);
+ BIO_free(in);
+ BIO_free(out);
+ BIO_free(benc);
+ BIO_free(b64);
EXIT(ret);
}
diff --git a/demos/bio/saccept.c b/demos/bio/saccept.c
index 8c75029384..505d98b68f 100644
--- a/demos/bio/saccept.c
+++ b/demos/bio/saccept.c
@@ -22,8 +22,7 @@ BIO *in = NULL;
void close_up()
{
- if (in != NULL)
- BIO_free(in);
+ BIO_free(in);
}
int main(int argc, char *argv[])
@@ -101,8 +100,7 @@ int main(int argc, char *argv[])
if (ret) {
ERR_print_errors_fp(stderr);
}
- if (in != NULL)
- BIO_free(in);
+ BIO_free(in);
exit(ret);
return (!ret);
}
diff --git a/demos/bio/server-arg.c b/demos/bio/server-arg.c
index 7ba54dbe50..4f65227e40 100644
--- a/demos/bio/server-arg.c
+++ b/demos/bio/server-arg.c
@@ -137,8 +137,7 @@ int main(int argc, char *argv[])
if (ret) {
ERR_print_errors_fp(stderr);
}
- if (in != NULL)
- BIO_free(in);
+ BIO_free(in);
exit(ret);
return (!ret);
}
diff --git a/demos/bio/server-conf.c b/demos/bio/server-conf.c
index a09bc9320d..5355839f4f 100644
--- a/demos/bio/server-conf.c
+++ b/demos/bio/server-conf.c
@@ -131,8 +131,7 @@ int main(int argc, char *argv[])
if (ret) {
ERR_print_errors_fp(stderr);
}
- if (in != NULL)
- BIO_free(in);
+ BIO_free(in);
exit(ret);
return (!ret);
}
diff --git a/demos/cms/cms_comp.c b/demos/cms/cms_comp.c
index 059152fe0e..e117d37b5e 100644
--- a/demos/cms/cms_comp.c
+++ b/demos/cms/cms_comp.c
@@ -50,10 +50,8 @@ int main(int argc, char **argv)
if (cms)
CMS_ContentInfo_free(cms);
- if (in)
- BIO_free(in);
- if (out)
- BIO_free(out);
+ BIO_free(in);
+ BIO_free(out);
return ret;
diff --git a/demos/cms/cms_ddec.c b/demos/cms/cms_ddec.c
index 37ac97fd01..7247e57112 100644
--- a/demos/cms/cms_ddec.c
+++ b/demos/cms/cms_ddec.c
@@ -75,14 +75,10 @@ int main(int argc, char **argv)
if (rkey)
EVP_PKEY_free(rkey);
- if (in)
- BIO_free(in);
- if (out)
- BIO_free(out);
- if (tbio)
- BIO_free(tbio);
- if (dcont)
- BIO_free(dcont);
+ BIO_free(in);
+ BIO_free(out);
+ BIO_free(tbio);
+ BIO_free(dcont);
return ret;
diff --git a/demos/cms/cms_dec.c b/demos/cms/cms_dec.c
index 3291eacab4..e9782d7c23 100644
--- a/demos/cms/cms_dec.c
+++ b/demos/cms/cms_dec.c
@@ -66,12 +66,9 @@ int main(int argc, char **argv)
if (rkey)
EVP_PKEY_free(rkey);
- if (in)
- BIO_free(in);
- if (out)
- BIO_free(out);
- if (tbio)
- BIO_free(tbio);
+ BIO_free(in);
+ BIO_free(out);
+ BIO_free(tbio);
return ret;
diff --git a/demos/cms/cms_denc.c b/demos/cms/cms_denc.c
index c86a5fd728..852671771c 100644
--- a/demos/cms/cms_denc.c
+++ b/demos/cms/cms_denc.c
@@ -84,14 +84,10 @@ int main(int argc, char **argv)
if (recips)
sk_X509_pop_free(recips, X509_free);
- if (in)
- BIO_free(in);
- if (out)
- BIO_free(out);
- if (dout)
- BIO_free(dout);
- if (tbio)
- BIO_free(tbio);
+ BIO_free(in);
+ BIO_free(out);
+ BIO_free(dout);
+ BIO_free(tbio);
return ret;
diff --git a/demos/cms/cms_enc.c b/demos/cms/cms_enc.c
index e8ecb48e27..4395e6b04f 100644
--- a/demos/cms/cms_enc.c
+++ b/demos/cms/cms_enc.c
@@ -80,12 +80,9 @@ int main(int argc, char **argv)
if (recips)
sk_X509_pop_free(recips, X509_free);
- if (in)
- BIO_free(in);
- if (out)
- BIO_free(out);
- if (tbio)
- BIO_free(tbio);
+ BIO_free(in);
+ BIO_free(out);
+ BIO_free(tbio);
return ret;
diff --git a/demos/cms/cms_sign.c b/demos/cms/cms_sign.c
index 4bf85d1384..9f2cff0dbe 100644
--- a/demos/cms/cms_sign.c
+++ b/demos/cms/cms_sign.c
@@ -76,12 +76,9 @@ int main(int argc, char **argv)
if (skey)
EVP_PKEY_free(skey);
- if (in)
- BIO_free(in);
- if (out)
- BIO_free(out);
- if (tbio)
- BIO_free(tbio);
+ BIO_free(in);
+ BIO_free(out);
+ BIO_free(tbio);
return ret;
diff --git a/demos/cms/cms_sign2.c b/demos/cms/cms_sign2.c
index 7e98a51713..23c6eb8f9f 100644
--- a/demos/cms/cms_sign2.c
+++ b/demos/cms/cms_sign2.c
@@ -90,12 +90,9 @@ int main(int argc, char **argv)
if (skey)
EVP_PKEY_free(skey2);
- if (in)
- BIO_free(in);
- if (out)
- BIO_free(out);
- if (tbio)
- BIO_free(tbio);
+ BIO_free(in);
+ BIO_free(out);
+ BIO_free(tbio);
return ret;
diff --git a/demos/cms/cms_uncomp.c b/demos/cms/cms_uncomp.c
index 392f4b4502..8d45834c34 100644
--- a/demos/cms/cms_uncomp.c
+++ b/demos/cms/cms_uncomp.c
@@ -45,10 +45,8 @@ int main(int argc, char **argv)
if (cms)
CMS_ContentInfo_free(cms);
- if (in)
- BIO_free(in);
- if (out)
- BIO_free(out);
+ BIO_free(in);
+ BIO_free(out);
return ret;
diff --git a/demos/cms/cms_ver.c b/demos/cms/cms_ver.c
index ca935517a7..422753163e 100644
--- a/demos/cms/cms_ver.c
+++ b/demos/cms/cms_ver.c
@@ -73,12 +73,9 @@ int main(int argc, char **argv)
if (cacert)
X509_free(cacert);
- if (in)
- BIO_free(in);
- if (out)
- BIO_free(out);
- if (tbio)
- BIO_free(tbio);
+ BIO_free(in);
+ BIO_free(out);
+ BIO_free(tbio);
return ret;
diff --git a/demos/smime/smdec.c b/demos/smime/smdec.c
index 6814d5199b..b50f8dffaf 100644
--- a/demos/smime/smdec.c
+++ b/demos/smime/smdec.c
@@ -66,12 +66,9 @@ int main(int argc, char **argv)
if (rkey)
EVP_PKEY_free(rkey);
- if (in)
- BIO_free(in);
- if (out)
- BIO_free(out);
- if (tbio)
- BIO_free(tbio);
+ BIO_free(in);
+ BIO_free(out);
+ BIO_free(tbio);
return ret;
diff --git a/demos/smime/smenc.c b/demos/smime/smenc.c
index 18bf7b1618..5a85537ad0 100644
--- a/demos/smime/smenc.c
+++ b/demos/smime/smenc.c
@@ -80,12 +80,9 @@ int main(int argc, char **argv)
if (recips)
sk_X509_pop_free(recips, X509_free);
- if (in)
- BIO_free(in);
- if (out)
- BIO_free(out);
- if (tbio)
- BIO_free(tbio);
+ BIO_free(in);
+ BIO_free(out);
+ BIO_free(tbio);
return ret;
diff --git a/demos/smime/smsign.c b/demos/smime/smsign.c
index c7bf86d370..6b9dfdd771 100644
--- a/demos/smime/smsign.c
+++ b/demos/smime/smsign.c
@@ -76,12 +76,9 @@ int main(int argc, char **argv)
if (skey)
EVP_PKEY_free(skey);
- if (in)
- BIO_free(in);
- if (out)
- BIO_free(out);
- if (tbio)
- BIO_free(tbio);
+ BIO_free(in);
+ BIO_free(out);
+ BIO_free(tbio);
return ret;
diff --git a/demos/smime/smsign2.c b/demos/smime/smsign2.c
index a116094341..5d9de35c46 100644
--- a/demos/smime/smsign2.c
+++ b/demos/smime/smsign2.c
@@ -90,12 +90,9 @@ int main(int argc, char **argv)
if (skey)
EVP_PKEY_free(skey2);
- if (in)
- BIO_free(in);
- if (out)
- BIO_free(out);
- if (tbio)
- BIO_free(tbio);
+ BIO_free(in);
+ BIO_free(out);
+ BIO_free(tbio);
return ret;
diff --git a/demos/smime/smver.c b/demos/smime/smver.c
index 21937df307..4088d3c38e 100644
--- a/demos/smime/smver.c
+++ b/demos/smime/smver.c
@@ -73,12 +73,9 @@ int main(int argc, char **argv)
if (cacert)
X509_free(cacert);
- if (in)
- BIO_free(in);
- if (out)
- BIO_free(out);
- if (tbio)
- BIO_free(tbio);
+ BIO_free(in);
+ BIO_free(out);
+ BIO_free(tbio);
return ret;
diff --git a/doc/crypto/BIO_new.pod b/doc/crypto/BIO_new.pod
index 2a245fc8de..76679f3da4 100644
--- a/doc/crypto/BIO_new.pod
+++ b/doc/crypto/BIO_new.pod
@@ -21,13 +21,16 @@ The BIO_new() function returns a new BIO using method B<type>.
BIO_set() sets the method of an already existing BIO.
BIO_free() frees up a single BIO, BIO_vfree() also frees up a single BIO
-but it does not return a value. Calling BIO_free() may also have some effect
+but it does not return a value.
+If B<a> is NULL nothing is done.
+Calling BIO_free() may also have some effect
on the underlying I/O structure, for example it may close the file being
referred to under certain circumstances. For more details see the individual
BIO_METHOD descriptions.
BIO_free_all() frees up an entire BIO chain, it does not halt if an error
occurs freeing up an individual BIO in the chain.
+If B<a> is NULL nothing is done.
=head1 RETURN VALUES
diff --git a/engines/e_chil.c b/engines/e_chil.c
index 19d29d7e62..c06ab1a1e6 100644
--- a/engines/e_chil.c
+++ b/engines/e_chil.c
@@ -656,8 +656,7 @@ static int hwcrhk_finish(ENGINE *e)
goto err;
}
err:
- if (logstream)
- BIO_free(logstream);
+ BIO_free(logstream);
hwcrhk_dso = NULL;
p_hwcrhk_Init = NULL;
p_hwcrhk_Finish = NULL;
@@ -693,10 +692,8 @@ static int hwcrhk_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f) (void))
BIO *bio = (BIO *)p;
CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
- if (logstream) {
- BIO_free(logstream);
- logstream = NULL;
- }
+ BIO_free(logstream);
+ logstream = NULL;
if (CRYPTO_add(&bio->references, 1, CRYPTO_LOCK_BIO) > 1)
logstream = bio;
else
diff --git a/engines/e_sureware.c b/engines/e_sureware.c
index 3c7b2b26bf..5e1786ca0f 100644
--- a/engines/e_sureware.c
+++ b/engines/e_sureware.c
@@ -404,10 +404,8 @@ static int surewarehk_ctrl(ENGINE *e, int cmd, long i, void *p,
{
BIO *bio = (BIO *)p;
CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
- if (logstream) {
- BIO_free(logstream);
- logstream = NULL;
- }
+ BIO_free(logstream);
+ logstream = NULL;
if (CRYPTO_add(&bio->references, 1, CRYPTO_LOCK_BIO) > 1)
logstream = bio;
else
@@ -596,8 +594,7 @@ static int surewarehk_finish(ENGINE *e)
goto err;
}
err:
- if (logstream)
- BIO_free(logstream);
+ BIO_free(logstream);
surewarehk_dso = NULL;
p_surewarehk_Init = NULL;
p_surewarehk_Finish = NULL;
diff --git a/ssl/bio_ssl.c b/ssl/bio_ssl.c
index 99f8b5e524..11a2aadc5f 100644
--- a/ssl/bio_ssl.c
+++ b/ssl/bio_ssl.c
@@ -503,10 +503,8 @@ BIO *BIO_new_buffer_ssl_connect(SSL_CTX *ctx)
goto err;
return (ret);
err:
- if (buf != NULL)
- BIO_free(buf);
- if (ssl != NULL)
- BIO_free(ssl);
+ BIO_free(buf);
+ BIO_free(ssl);
#endif
return (NULL);
}
@@ -524,8 +522,7 @@ BIO *BIO_new_ssl_connect(SSL_CTX *ctx)
goto err;
return (ret);
err:
- if (con != NULL)
- BIO_free(con);
+ BIO_free(con);
#endif
return (NULL);
}
diff --git a/ssl/s3_enc.c b/ssl/s3_enc.c
index bcefe12769..94f6dd0647 100644
--- a/ssl/s3_enc.c
+++ b/ssl/s3_enc.c
@@ -558,8 +558,7 @@ int ssl3_enc(SSL *s, int send)
void ssl3_init_finished_mac(SSL *s)
{
- if (s->s3->handshake_buffer)
- BIO_free(s->s3->handshake_buffer);
+ BIO_free(s->s3->handshake_buffer);
if (s->s3->handshake_dgst)
ssl3_free_digest_list(s);
s->s3->handshake_buffer = BIO_new(BIO_s_mem());
diff --git a/ssl/s3_lib.c b/ssl/s3_lib.c
index 9893930eef..bed4a4e72d 100644
--- a/ssl/s3_lib.c
+++ b/ssl/s3_lib.c
@@ -3147,9 +3147,7 @@ void ssl3_free(SSL *s)
if (s->s3->tmp.ca_names != NULL)
sk_X509_NAME_pop_free(s->s3->tmp.ca_names, X509_NAME_free);
- if (s->s3->handshake_buffer) {
- BIO_free(s->s3->handshake_buffer);
- }
+ BIO_free(s->s3->handshake_buffer);
if (s->s3->handshake_dgst)
ssl3_free_digest_list(s);
#ifndef OPENSSL_NO_TLSEXT
@@ -3200,10 +3198,8 @@ void ssl3_clear(SSL *s)
rlen = s->s3->rbuf.len;
wlen = s->s3->wbuf.len;
init_extra = s->s3->init_extra;
- if (s->s3->handshake_buffer) {
- BIO_free(s->s3->handshake_buffer);
- s->s3->handshake_buffer = NULL;
- }
+ BIO_free(s->s3->handshake_buffer);
+ s->s3->handshake_buffer = NULL;
if (s->s3->handshake_dgst) {
ssl3_free_digest_list(s);
}
diff --git a/ssl/ssl_cert.c b/ssl/ssl_cert.c
index cbfe7bb416..367f7a9603 100644
--- a/ssl/ssl_cert.c
+++ b/ssl/ssl_cert.c
@@ -877,8 +877,7 @@ STACK_OF(X509_NAME) *SSL_load_client_CA_file(const char *file)
}
if (sk != NULL)
sk_X509_NAME_free(sk);
- if (in != NULL)
- BIO_free(in);
+ BIO_free(in);
if (x != NULL)
X509_free(x);
if (ret != NULL)
@@ -938,8 +937,7 @@ int SSL_add_file_cert_subjects_to_stack(STACK_OF(X509_NAME) *stack,
err:
ret = 0;
}
- if (in != NULL)
- BIO_free(in);
+ BIO_free(in);
if (x != NULL)
X509_free(x);
diff --git a/ssl/ssl_conf.c b/ssl/ssl_conf.c
index 0fd6c1f1be..43821f6f37 100644
--- a/ssl/ssl_conf.c
+++ b/ssl/ssl_conf.c
@@ -438,8 +438,7 @@ static int cmd_DHParameters(SSL_CONF_CTX *cctx, const char *value)
rv = SSL_set_tmp_dh(cctx->ssl, dh);
end:
DH_free(dh);
- if (in)
- BIO_free(in);
+ BIO_free(in);
return rv > 0;
}
#endif
diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c
index 29bbc03e4c..1e9ad91c46 100644
--- a/ssl/ssl_lib.c
+++ b/ssl/ssl_lib.c
@@ -543,9 +543,8 @@ void SSL_free(SSL *s)
BIO_free(s->bbio);
s->bbio = NULL;
}
- if (s->rbio != NULL)
- BIO_free_all(s->rbio);
- if ((s->wbio != NULL) && (s->wbio != s->rbio))
+ BIO_free_all(s->rbio);
+ if (s->wbio != s->rbio)
BIO_free_all(s->wbio);
if (s->init_buf != NULL)
@@ -621,7 +620,7 @@ void SSL_free(SSL *s)
void SSL_set_rbio(SSL *s, BIO *rbio)
{
- if ((s->rbio != NULL) && (s->rbio != rbio))
+ if (s->rbio != rbio)
BIO_free_all(s->rbio);
s->rbio = rbio;
}
@@ -637,7 +636,7 @@ void SSL_set_wbio(SSL *s, BIO *wbio)
s->bbio->next_bio = NULL;
}
}
- if ((s->wbio != NULL) && (s->wbio != wbio) && (s->rbio != s->wbio))
+ if (s->wbio != wbio && s->rbio != s->wbio)
BIO_free_all(s->wbio);
s->wbio = wbio;
}
diff --git a/ssl/ssl_rsa.c b/ssl/ssl_rsa.c
index 60a68340d1..90fe8c8af9 100644
--- a/ssl/ssl_rsa.c
+++ b/ssl/ssl_rsa.c
@@ -121,8 +121,7 @@ int SSL_use_certificate_file(SSL *ssl, const char *file, int type)
end:
if (x != NULL)
X509_free(x);
- if (in != NULL)
- BIO_free(in);
+ BIO_free(in);
return (ret);
}
#endif
@@ -262,8 +261,7 @@ int SSL_use_RSAPrivateKey_file(SSL *ssl, const char *file, int type)
ret = SSL_use_RSAPrivateKey(ssl, rsa);
RSA_free(rsa);
end:
- if (in != NULL)
- BIO_free(in);
+ BIO_free(in);
return (ret);
}
# endif
@@ -335,8 +333,7 @@ int SSL_use_PrivateKey_file(SSL *ssl, const char *file, int type)
ret = SSL_use_PrivateKey(ssl, pkey);
EVP_PKEY_free(pkey);
end:
- if (in != NULL)
- BIO_free(in);
+ BIO_free(in);
return (ret);
}
#endif
@@ -470,8 +467,7 @@ int SSL_CTX_use_certificate_file(SSL_CTX *ctx, const char *file, int type)
end:
if (x != NULL)
X509_free(x);
- if (in != NULL)
- BIO_free(in);
+ BIO_free(in);
return (ret);
}
#endif
@@ -552,8 +548,7 @@ int SSL_CTX_use_RSAPrivateKey_file(SSL_CTX *ctx, const char *file, int type)
ret = SSL_CTX_use_RSAPrivateKey(ctx, rsa);
RSA_free(rsa);
end:
- if (in != NULL)
- BIO_free(in);
+ BIO_free(in);
return (ret);
}
# endif
@@ -622,8 +617,7 @@ int SSL_CTX_use_PrivateKey_file(SSL_CTX *ctx, const char *file, int type)
ret = SSL_CTX_use_PrivateKey(ctx, pkey);
EVP_PKEY_free(pkey);
end:
- if (in != NULL)
- BIO_free(in);
+ BIO_free(in);
return (ret);
}
#endif
@@ -726,8 +720,7 @@ int SSL_CTX_use_certificate_chain_file(SSL_CTX *ctx, const char *file)
end:
if (x != NULL)
X509_free(x);
- if (in != NULL)
- BIO_free(in);
+ BIO_free(in);
return (ret);
}
#endif
@@ -991,8 +984,7 @@ int SSL_CTX_use_serverinfo_file(SSL_CTX *ctx, const char *file)
OPENSSL_free(header);
OPENSSL_free(extension);
OPENSSL_free(serverinfo);
- if (bin != NULL)
- BIO_free(bin);
+ BIO_free(bin);
return ret;
}
# endif /* OPENSSL_NO_STDIO */
diff --git a/ssl/ssl_task.c b/ssl/ssl_task.c
index ab37cc6bef..d5ca89feb8 100644
--- a/ssl/ssl_task.c
+++ b/ssl/ssl_task.c
@@ -381,13 +381,9 @@ int doit(io_channel chan, SSL_CTX *s_ctx)
s_ssl->rbio = NULL;
s_ssl->wbio = NULL;
- if (c_to_s != NULL)
- BIO_free(c_to_s);
- if (s_to_c != NULL)
- BIO_free(s_to_c);
- if (c_bio != NULL)
- BIO_free(c_bio);
- if (s_bio != NULL)
- BIO_free(s_bio);
+ BIO_free(c_to_s);
+ BIO_free(s_to_c);
+ BIO_free(c_bio);
+ BIO_free(s_bio);
return (0);
}
diff --git a/ssl/ssltest.c b/ssl/ssltest.c
index d244ba3cd9..508fedd613 100644
--- a/ssl/ssltest.c
+++ b/ssl/ssltest.c
@@ -1798,8 +1798,7 @@ int main(int argc, char *argv[])
SSL_CONF_CTX_free(c_cctx);
sk_OPENSSL_STRING_free(conf_args);
- if (bio_stdout != NULL)
- BIO_free(bio_stdout);
+ BIO_free(bio_stdout);
#ifndef OPENSSL_NO_RSA
free_tmp_rsa();
@@ -1812,8 +1811,7 @@ int main(int argc, char *argv[])
ERR_remove_thread_state(NULL);
EVP_cleanup();
CRYPTO_mem_leaks(bio_err);
- if (bio_err != NULL)
- BIO_free(bio_err);
+ BIO_free(bio_err);
EXIT(ret);
}
@@ -2173,18 +2171,12 @@ int doit_biopair(SSL *s_ssl, SSL *c_ssl, long count,
err:
ERR_print_errors(bio_err);
- if (server)
- BIO_free(server);
- if (server_io)
- BIO_free(server_io);
- if (client)
- BIO_free(client);
- if (client_io)
- BIO_free(client_io);
- if (s_ssl_bio)
- BIO_free(s_ssl_bio);
- if (c_ssl_bio)
- BIO_free(c_ssl_bio);
+ BIO_free(server);
+ BIO_free(server_io);
+ BIO_free(client);
+ BIO_free(client_io);
+ BIO_free(s_ssl_bio);
+ BIO_free(c_ssl_bio);
return ret;
}
@@ -2468,14 +2460,10 @@ int doit(SSL *s_ssl, SSL *c_ssl, long count)
c_ssl->wbio = NULL;
}
- if (c_to_s != NULL)
- BIO_free(c_to_s);
- if (s_to_c != NULL)
- BIO_free(s_to_c);
- if (c_bio != NULL)
- BIO_free_all(c_bio);
- if (s_bio != NULL)
- BIO_free_all(s_bio);
+ BIO_free(c_to_s);
+ BIO_free(s_to_c);
+ BIO_free_all(c_bio);
+ BIO_free_all(s_bio);
if (cbuf)
OPENSSL_free(cbuf);