diff options
author | Rich Salz <rsalz@openssl.org> | 2015-04-30 17:33:59 -0400 |
---|---|---|
committer | Rich Salz <rsalz@openssl.org> | 2015-04-30 17:33:59 -0400 |
commit | 222561fe8ef510f336417a666f69f81ddc9b8fe4 (patch) | |
tree | 70bc6af70550022bc7b7af45bd3c6d64d7fc2680 /demos | |
parent | 2ace745022f5af0709297e96eb0b0829c87c4291 (diff) | |
download | openssl-222561fe8ef510f336417a666f69f81ddc9b8fe4.tar.gz |
free NULL cleanup 5a
Don't check for NULL before calling a free routine. This gets X509_.*free:
x509_name_ex_free X509_policy_tree_free X509_VERIFY_PARAM_free
X509_STORE_free X509_STORE_CTX_free X509_PKEY_free
X509_OBJECT_free_contents X509_LOOKUP_free X509_INFO_free
Reviewed-by: Richard Levitte <levitte@openssl.org>
Diffstat (limited to 'demos')
-rw-r--r-- | demos/cms/cms_ddec.c | 3 | ||||
-rw-r--r-- | demos/cms/cms_dec.c | 3 | ||||
-rw-r--r-- | demos/cms/cms_denc.c | 6 | ||||
-rw-r--r-- | demos/cms/cms_enc.c | 6 | ||||
-rw-r--r-- | demos/cms/cms_sign.c | 3 | ||||
-rw-r--r-- | demos/cms/cms_sign2.c | 8 | ||||
-rw-r--r-- | demos/cms/cms_ver.c | 3 | ||||
-rw-r--r-- | demos/easy_tls/easy-tls.c | 3 | ||||
-rw-r--r-- | demos/smime/smdec.c | 3 | ||||
-rw-r--r-- | demos/smime/smenc.c | 6 | ||||
-rw-r--r-- | demos/smime/smsign.c | 3 | ||||
-rw-r--r-- | demos/smime/smsign2.c | 6 | ||||
-rw-r--r-- | demos/smime/smver.c | 3 | ||||
-rw-r--r-- | demos/spkigen.c | 3 |
14 files changed, 19 insertions, 40 deletions
diff --git a/demos/cms/cms_ddec.c b/demos/cms/cms_ddec.c index 1e06cea5c7..36bb4ee081 100644 --- a/demos/cms/cms_ddec.c +++ b/demos/cms/cms_ddec.c @@ -70,8 +70,7 @@ int main(int argc, char **argv) if (cms) CMS_ContentInfo_free(cms); - if (rcert) - X509_free(rcert); + X509_free(rcert); EVP_PKEY_free(rkey); BIO_free(in); diff --git a/demos/cms/cms_dec.c b/demos/cms/cms_dec.c index 71a0e4ffdd..832b54d43c 100644 --- a/demos/cms/cms_dec.c +++ b/demos/cms/cms_dec.c @@ -61,8 +61,7 @@ int main(int argc, char **argv) if (cms) CMS_ContentInfo_free(cms); - if (rcert) - X509_free(rcert); + X509_free(rcert); EVP_PKEY_free(rkey); BIO_free(in); diff --git a/demos/cms/cms_denc.c b/demos/cms/cms_denc.c index 852671771c..f91fec1df3 100644 --- a/demos/cms/cms_denc.c +++ b/demos/cms/cms_denc.c @@ -79,10 +79,8 @@ int main(int argc, char **argv) if (cms) CMS_ContentInfo_free(cms); - if (rcert) - X509_free(rcert); - if (recips) - sk_X509_pop_free(recips, X509_free); + X509_free(rcert); + sk_X509_pop_free(recips, X509_free); BIO_free(in); BIO_free(out); diff --git a/demos/cms/cms_enc.c b/demos/cms/cms_enc.c index 4395e6b04f..ba62f7920e 100644 --- a/demos/cms/cms_enc.c +++ b/demos/cms/cms_enc.c @@ -75,10 +75,8 @@ int main(int argc, char **argv) if (cms) CMS_ContentInfo_free(cms); - if (rcert) - X509_free(rcert); - if (recips) - sk_X509_pop_free(recips, X509_free); + X509_free(rcert); + sk_X509_pop_free(recips, X509_free); BIO_free(in); BIO_free(out); diff --git a/demos/cms/cms_sign.c b/demos/cms/cms_sign.c index 3ad5ce8c18..e9871dfd36 100644 --- a/demos/cms/cms_sign.c +++ b/demos/cms/cms_sign.c @@ -71,8 +71,7 @@ int main(int argc, char **argv) if (cms) CMS_ContentInfo_free(cms); - if (scert) - X509_free(scert); + X509_free(scert); EVP_PKEY_free(skey); BIO_free(in); diff --git a/demos/cms/cms_sign2.c b/demos/cms/cms_sign2.c index 3276de1b2a..127f5860ee 100644 --- a/demos/cms/cms_sign2.c +++ b/demos/cms/cms_sign2.c @@ -80,14 +80,10 @@ int main(int argc, char **argv) if (cms) CMS_ContentInfo_free(cms); - if (scert) - X509_free(scert); + X509_free(scert); EVP_PKEY_free(skey); - - if (scert2) - X509_free(scert2); + X509_free(scert2); EVP_PKEY_free(skey2); - BIO_free(in); BIO_free(out); BIO_free(tbio); diff --git a/demos/cms/cms_ver.c b/demos/cms/cms_ver.c index 422753163e..0f34bbf335 100644 --- a/demos/cms/cms_ver.c +++ b/demos/cms/cms_ver.c @@ -70,8 +70,7 @@ int main(int argc, char **argv) if (cms) CMS_ContentInfo_free(cms); - if (cacert) - X509_free(cacert); + X509_free(cacert); BIO_free(in); BIO_free(out); diff --git a/demos/easy_tls/easy-tls.c b/demos/easy_tls/easy-tls.c index 1a0a03abe6..9346720dae 100644 --- a/demos/easy_tls/easy-tls.c +++ b/demos/easy_tls/easy-tls.c @@ -943,8 +943,7 @@ static void write_info(SSL *ssl, int *info_fd) peercert = SSL_get_peer_certificate(ssl); tls_get_x509_subject_name_oneline(peercert, &peer); - if (peercert != NULL) - X509_free(peercert); + X509_free(peercert); } if (peer.str[0] == '\0') v_ok = '0'; /* no cert at all */ diff --git a/demos/smime/smdec.c b/demos/smime/smdec.c index 9752dea1f9..f1a987a34e 100644 --- a/demos/smime/smdec.c +++ b/demos/smime/smdec.c @@ -58,8 +58,7 @@ int main(int argc, char **argv) ERR_print_errors_fp(stderr); } PKCS7_free(p7); - if (rcert) - X509_free(rcert); + X509_free(rcert); EVP_PKEY_free(rkey); BIO_free(in); BIO_free(out); diff --git a/demos/smime/smenc.c b/demos/smime/smenc.c index 2e594ee89e..79fe2d0e10 100644 --- a/demos/smime/smenc.c +++ b/demos/smime/smenc.c @@ -72,10 +72,8 @@ int main(int argc, char **argv) ERR_print_errors_fp(stderr); } PKCS7_free(p7); - if (rcert) - X509_free(rcert); - if (recips) - sk_X509_pop_free(recips, X509_free); + X509_free(rcert); + sk_X509_pop_free(recips, X509_free); BIO_free(in); BIO_free(out); BIO_free(tbio); diff --git a/demos/smime/smsign.c b/demos/smime/smsign.c index 91ab8e475d..8505e7140b 100644 --- a/demos/smime/smsign.c +++ b/demos/smime/smsign.c @@ -68,8 +68,7 @@ int main(int argc, char **argv) ERR_print_errors_fp(stderr); } PKCS7_free(p7); - if (scert) - X509_free(scert); + X509_free(scert); EVP_PKEY_free(skey); BIO_free(in); BIO_free(out); diff --git a/demos/smime/smsign2.c b/demos/smime/smsign2.c index 0ad709d041..415ecf395f 100644 --- a/demos/smime/smsign2.c +++ b/demos/smime/smsign2.c @@ -76,11 +76,9 @@ int main(int argc, char **argv) ERR_print_errors_fp(stderr); } PKCS7_free(p7); - if (scert) - X509_free(scert); + X509_free(scert); EVP_PKEY_free(skey); - if (scert2) - X509_free(scert2); + X509_free(scert2); EVP_PKEY_free(skey2); BIO_free(in); BIO_free(out); diff --git a/demos/smime/smver.c b/demos/smime/smver.c index c4b6e751a9..13ba18b9b9 100644 --- a/demos/smime/smver.c +++ b/demos/smime/smver.c @@ -66,8 +66,7 @@ int main(int argc, char **argv) ERR_print_errors_fp(stderr); } PKCS7_free(p7); - if (cacert) - X509_free(cacert); + X509_free(cacert); BIO_free(in); BIO_free(out); BIO_free(tbio); diff --git a/demos/spkigen.c b/demos/spkigen.c index c272a8c223..7df8f34c0c 100644 --- a/demos/spkigen.c +++ b/demos/spkigen.c @@ -166,7 +166,6 @@ EVP_PKEY *pkey; pk = NULL; ok = 1; err: - if (pk != NULL) - X509_PUBKEY_free(pk); + X509_PUBKEY_free(pk); return (ok); } |