free NULL cleanup

This commit handles BIO_ACCEPT_free BIO_CB_FREE BIO_CONNECT_free
BIO_free BIO_free_all BIO_vfree

Reviewed-by: Matt Caswell <matt@openssl.org>
This commit is contained in:
Rich Salz 2015-03-25 11:31:18 -04:00
parent 2011b169fa
commit ca3a82c3b3
76 changed files with 201 additions and 389 deletions

View File

@ -1114,8 +1114,7 @@ EVP_PKEY *load_pubkey(BIO *err, const char *file, int format, int maybe_stdin,
goto end; goto end;
} }
end: end:
if (key != NULL) BIO_free(key);
BIO_free(key);
if (pkey == NULL) if (pkey == NULL)
BIO_printf(err, "unable to load %s\n", key_descrip); BIO_printf(err, "unable to load %s\n", key_descrip);
return (pkey); return (pkey);
@ -1682,8 +1681,7 @@ BIGNUM *load_serial(char *serialfile, int create, ASN1_INTEGER **retai)
ai = NULL; ai = NULL;
} }
err: err:
if (in != NULL) BIO_free(in);
BIO_free(in);
if (ai != NULL) if (ai != NULL)
ASN1_INTEGER_free(ai); ASN1_INTEGER_free(ai);
return (ret); return (ret);
@ -1741,8 +1739,7 @@ int save_serial(char *serialfile, char *suffix, BIGNUM *serial,
ai = NULL; ai = NULL;
} }
err: err:
if (out != NULL) BIO_free_all(out);
BIO_free_all(out);
if (ai != NULL) if (ai != NULL)
ASN1_INTEGER_free(ai); ASN1_INTEGER_free(ai);
return (ret); return (ret);
@ -1896,8 +1893,7 @@ CA_DB *load_index(char *dbfile, DB_ATTR *db_attr)
NCONF_free(dbattr_conf); NCONF_free(dbattr_conf);
if (tmpdb) if (tmpdb)
TXT_DB_free(tmpdb); TXT_DB_free(tmpdb);
if (in) BIO_free_all(in);
BIO_free_all(in);
return retdb; return retdb;
} }

View File

@ -370,12 +370,9 @@ int MAIN(int argc, char **argv)
ret = 0; ret = 0;
end: end:
BIO_free(derout); BIO_free(derout);
if (in != NULL) BIO_free(in);
BIO_free(in); BIO_free_all(out);
if (out != NULL) BIO_free(b64);
BIO_free_all(out);
if (b64 != NULL)
BIO_free(b64);
if (ret != 0) if (ret != 0)
ERR_print_errors(bio_err); ERR_print_errors(bio_err);
if (buf != NULL) if (buf != NULL)

View File

@ -1566,8 +1566,7 @@ static int certify(X509 **xret, char *infile, EVP_PKEY *pkey, X509 *x509,
err: err:
if (req != NULL) if (req != NULL)
X509_REQ_free(req); X509_REQ_free(req);
if (in != NULL) BIO_free(in);
BIO_free(in);
return (ok); return (ok);
} }

View File

@ -227,8 +227,7 @@ int MAIN(int argc, char **argv)
SSL_CTX_free(ctx); SSL_CTX_free(ctx);
if (ssl != NULL) if (ssl != NULL)
SSL_free(ssl); SSL_free(ssl);
if (STDout != NULL) BIO_free_all(STDout);
BIO_free_all(STDout);
apps_shutdown(); apps_shutdown();
OPENSSL_EXIT(ret); OPENSSL_EXIT(ret);
} }

View File

@ -268,10 +268,8 @@ int MAIN(int argc, char **argv)
} }
ret = 0; ret = 0;
end: end:
if (in != NULL) BIO_free(in);
BIO_free(in); BIO_free_all(out);
if (out != NULL)
BIO_free_all(out);
if (p7 != NULL) if (p7 != NULL)
PKCS7_free(p7); PKCS7_free(p7);
if (crl != NULL) if (crl != NULL)
@ -326,8 +324,7 @@ static int add_certs_from_file(STACK_OF(X509) *stack, char *certfile)
ret = count; ret = count;
end: end:
/* never need to OPENSSL_free x */ /* never need to OPENSSL_free x */
if (in != NULL) BIO_free(in);
BIO_free(in);
if (sk != NULL) if (sk != NULL)
sk_X509_INFO_free(sk); sk_X509_INFO_free(sk);
return (ret); return (ret);

View File

@ -518,8 +518,7 @@ int MAIN(int argc, char **argv)
OPENSSL_cleanse(buf, BUFSIZE); OPENSSL_cleanse(buf, BUFSIZE);
OPENSSL_free(buf); OPENSSL_free(buf);
} }
if (in != NULL) BIO_free(in);
BIO_free(in);
if (passin) if (passin)
OPENSSL_free(passin); OPENSSL_free(passin);
BIO_free_all(out); BIO_free_all(out);
@ -530,8 +529,7 @@ int MAIN(int argc, char **argv)
sk_OPENSSL_STRING_free(macopts); sk_OPENSSL_STRING_free(macopts);
if (sigbuf) if (sigbuf)
OPENSSL_free(sigbuf); OPENSSL_free(sigbuf);
if (bmd != NULL) BIO_free(bmd);
BIO_free(bmd);
apps_shutdown(); apps_shutdown();
OPENSSL_EXIT(err); OPENSSL_EXIT(err);
} }

View File

@ -310,10 +310,8 @@ int MAIN(int argc, char **argv)
} }
ret = 0; ret = 0;
end: end:
if (in != NULL) BIO_free(in);
BIO_free(in); BIO_free_all(out);
if (out != NULL)
BIO_free_all(out);
DH_free(dh); DH_free(dh);
apps_shutdown(); apps_shutdown();
OPENSSL_EXIT(ret); OPENSSL_EXIT(ret);

View File

@ -515,10 +515,8 @@ int MAIN(int argc, char **argv)
} }
ret = 0; ret = 0;
end: end:
if (in != NULL) BIO_free(in);
BIO_free(in); BIO_free_all(out);
if (out != NULL)
BIO_free_all(out);
DH_free(dh); DH_free(dh);
apps_shutdown(); apps_shutdown();
OPENSSL_EXIT(ret); OPENSSL_EXIT(ret);

View File

@ -356,10 +356,8 @@ int MAIN(int argc, char **argv)
} else } else
ret = 0; ret = 0;
end: end:
if (in != NULL) BIO_free(in);
BIO_free(in); BIO_free_all(out);
if (out != NULL)
BIO_free_all(out);
DSA_free(dsa); DSA_free(dsa);
if (passin) if (passin)
OPENSSL_free(passin); OPENSSL_free(passin);

View File

@ -434,10 +434,8 @@ int MAIN(int argc, char **argv)
end: end:
if (cb != NULL) if (cb != NULL)
BN_GENCB_free(cb); BN_GENCB_free(cb);
if (in != NULL) BIO_free(in);
BIO_free(in); BIO_free_all(out);
if (out != NULL)
BIO_free_all(out);
DSA_free(dsa); DSA_free(dsa);
apps_shutdown(); apps_shutdown();
OPENSSL_EXIT(ret); OPENSSL_EXIT(ret);

View File

@ -343,10 +343,8 @@ int MAIN(int argc, char **argv)
} else } else
ret = 0; ret = 0;
end: end:
if (in) BIO_free(in);
BIO_free(in); BIO_free_all(out);
if (out)
BIO_free_all(out);
if (eckey) if (eckey)
EC_KEY_free(eckey); EC_KEY_free(eckey);
if (passin) if (passin)

View File

@ -621,10 +621,8 @@ int MAIN(int argc, char **argv)
BN_free(ec_cofactor); BN_free(ec_cofactor);
if (buffer) if (buffer)
OPENSSL_free(buffer); OPENSSL_free(buffer);
if (in != NULL) BIO_free(in);
BIO_free(in); BIO_free_all(out);
if (out != NULL)
BIO_free_all(out);
if (group != NULL) if (group != NULL)
EC_GROUP_free(group); EC_GROUP_free(group);
apps_shutdown(); apps_shutdown();

View File

@ -657,17 +657,12 @@ int MAIN(int argc, char **argv)
OPENSSL_free(strbuf); OPENSSL_free(strbuf);
if (buff != NULL) if (buff != NULL)
OPENSSL_free(buff); OPENSSL_free(buff);
if (in != NULL) BIO_free(in);
BIO_free(in); BIO_free_all(out);
if (out != NULL) BIO_free(benc);
BIO_free_all(out); BIO_free(b64);
if (benc != NULL)
BIO_free(benc);
if (b64 != NULL)
BIO_free(b64);
#ifdef ZLIB #ifdef ZLIB
if (bzl != NULL) BIO_free(bzl);
BIO_free(bzl);
#endif #endif
if (pass) if (pass)
OPENSSL_free(pass); OPENSSL_free(pass);

View File

@ -497,8 +497,7 @@ int MAIN(int argc, char **argv)
sk_OPENSSL_STRING_pop_free(engines, identity); sk_OPENSSL_STRING_pop_free(engines, identity);
sk_OPENSSL_STRING_pop_free(pre_cmds, identity); sk_OPENSSL_STRING_pop_free(pre_cmds, identity);
sk_OPENSSL_STRING_pop_free(post_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(); apps_shutdown();
OPENSSL_EXIT(ret); OPENSSL_EXIT(ret);
} }

View File

@ -100,8 +100,7 @@ int MAIN(int argc, char **argv)
lh_ERR_STRING_DATA_node_usage_stats_bio(ERR_get_string_table(), lh_ERR_STRING_DATA_node_usage_stats_bio(ERR_get_string_table(),
out); out);
} }
if (out != NULL) BIO_free_all(out);
BIO_free_all(out);
argc--; argc--;
argv++; argv++;
} }

View File

@ -210,8 +210,7 @@ int MAIN(int argc, char **argv)
end: end:
if (ret != 0) if (ret != 0)
ERR_print_errors(bio_err); ERR_print_errors(bio_err);
if (out != NULL) BIO_free_all(out);
BIO_free_all(out);
DH_free(dh); DH_free(dh);
if (cb != NULL) if (cb != NULL)
BN_GENCB_free(cb); BN_GENCB_free(cb);

View File

@ -267,10 +267,8 @@ int MAIN(int argc, char **argv)
end: end:
if (ret != 0) if (ret != 0)
ERR_print_errors(bio_err); ERR_print_errors(bio_err);
if (in != NULL) BIO_free(in);
BIO_free(in); BIO_free_all(out);
if (out != NULL)
BIO_free_all(out);
DSA_free(dsa); DSA_free(dsa);
if (passout) if (passout)
OPENSSL_free(passout); OPENSSL_free(passout);

View File

@ -272,8 +272,7 @@ int MAIN(int argc, char **argv)
EVP_PKEY_free(pkey); EVP_PKEY_free(pkey);
if (ctx) if (ctx)
EVP_PKEY_CTX_free(ctx); EVP_PKEY_CTX_free(ctx);
if (out) BIO_free_all(out);
BIO_free_all(out);
BIO_free(in); BIO_free(in);
if (pass) if (pass)
OPENSSL_free(pass); OPENSSL_free(pass);

View File

@ -312,8 +312,7 @@ int MAIN(int argc, char **argv)
if (cb) if (cb)
BN_GENCB_free(cb); BN_GENCB_free(cb);
RSA_free(rsa); RSA_free(rsa);
if (out) BIO_free_all(out);
BIO_free_all(out);
if (passout) if (passout)
OPENSSL_free(passout); OPENSSL_free(passout);
if (ret != 0) if (ret != 0)

View File

@ -1362,8 +1362,7 @@ OCSP_RESPONSE *process_responder(BIO *err, OCSP_REQUEST *req,
if (!resp) if (!resp)
BIO_printf(bio_err, "Error querying OCSP responder\n"); BIO_printf(bio_err, "Error querying OCSP responder\n");
end: end:
if (cbio) BIO_free_all(cbio);
BIO_free_all(cbio);
if (ctx) if (ctx)
SSL_CTX_free(ctx); SSL_CTX_free(ctx);
return resp; return resp;

View File

@ -431,10 +431,8 @@ int main(int Argc, char *ARGV[])
#endif #endif
apps_shutdown(); apps_shutdown();
CRYPTO_mem_leaks(bio_err); CRYPTO_mem_leaks(bio_err);
if (bio_err != NULL) { BIO_free(bio_err);
BIO_free(bio_err); bio_err = NULL;
bio_err = NULL;
}
OPENSSL_EXIT(ret); OPENSSL_EXIT(ret);
} }

View File

@ -273,10 +273,8 @@ int MAIN(int argc, char **argv)
OPENSSL_free(salt_malloc); OPENSSL_free(salt_malloc);
if (passwd_malloc) if (passwd_malloc)
OPENSSL_free(passwd_malloc); OPENSSL_free(passwd_malloc);
if (in) BIO_free(in);
BIO_free(in); BIO_free_all(out);
if (out)
BIO_free_all(out);
apps_shutdown(); apps_shutdown();
OPENSSL_EXIT(ret); OPENSSL_EXIT(ret);
} }

View File

@ -299,10 +299,8 @@ int MAIN(int argc, char **argv)
end: end:
if (p7 != NULL) if (p7 != NULL)
PKCS7_free(p7); PKCS7_free(p7);
if (in != NULL) BIO_free(in);
BIO_free(in); BIO_free_all(out);
if (out != NULL)
BIO_free_all(out);
apps_shutdown(); apps_shutdown();
OPENSSL_EXIT(ret); OPENSSL_EXIT(ret);
} }

View File

@ -222,8 +222,7 @@ int MAIN(int argc, char **argv)
err: err:
ERR_print_errors(bio_err); ERR_print_errors(bio_err);
if (out) BIO_free_all(out);
BIO_free_all(out);
apps_shutdown(); apps_shutdown();
OPENSSL_EXIT(ret); OPENSSL_EXIT(ret);
} }

View File

@ -422,8 +422,7 @@ int MAIN(int argc, char **argv)
} else } else
ret = 0; ret = 0;
end: end:
if (out != NULL) BIO_free_all(out);
BIO_free_all(out);
RSA_free(rsa); RSA_free(rsa);
if (passin) if (passin)
OPENSSL_free(passin); OPENSSL_free(passin);

View File

@ -2059,14 +2059,10 @@ int MAIN(int argc, char **argv)
OPENSSL_cleanse(mbuf, BUFSIZZ); OPENSSL_cleanse(mbuf, BUFSIZZ);
OPENSSL_free(mbuf); OPENSSL_free(mbuf);
} }
if (bio_c_out != NULL) { BIO_free(bio_c_out);
BIO_free(bio_c_out); bio_c_out = NULL;
bio_c_out = NULL; BIO_free(bio_c_msg);
} bio_c_msg = NULL;
if (bio_c_msg != NULL) {
BIO_free(bio_c_msg);
bio_c_msg = NULL;
}
apps_shutdown(); apps_shutdown();
OPENSSL_EXIT(ret); OPENSSL_EXIT(ret);
} }

View File

@ -2039,8 +2039,7 @@ int MAIN(int argc, char *argv[])
X509_free(s_cert2); X509_free(s_cert2);
if (s_key2) if (s_key2)
EVP_PKEY_free(s_key2); EVP_PKEY_free(s_key2);
if (serverinfo_in != NULL) BIO_free(serverinfo_in);
BIO_free(serverinfo_in);
# ifndef OPENSSL_NO_NEXTPROTONEG # ifndef OPENSSL_NO_NEXTPROTONEG
if (next_proto.data) if (next_proto.data)
OPENSSL_free(next_proto.data); OPENSSL_free(next_proto.data);
@ -2057,14 +2056,10 @@ int MAIN(int argc, char *argv[])
if (jpake_secret && psk_key) if (jpake_secret && psk_key)
OPENSSL_free(psk_key); OPENSSL_free(psk_key);
#endif #endif
if (bio_s_out != NULL) { BIO_free(bio_s_out);
BIO_free(bio_s_out); bio_s_out = NULL;
bio_s_out = NULL; BIO_free(bio_s_msg);
} bio_s_msg = NULL;
if (bio_s_msg != NULL) {
BIO_free(bio_s_msg);
bio_s_msg = NULL;
}
apps_shutdown(); apps_shutdown();
OPENSSL_EXIT(ret); OPENSSL_EXIT(ret);
} }
@ -2661,8 +2656,7 @@ static DH *load_dh_param(const char *dhfile)
goto err; goto err;
ret = PEM_read_bio_DHparams(bio, NULL, NULL, NULL); ret = PEM_read_bio_DHparams(bio, NULL, NULL, NULL);
err: err:
if (bio != NULL) BIO_free(bio);
BIO_free(bio);
return (ret); return (ret);
} }
#endif #endif
@ -3021,9 +3015,7 @@ static int www_body(char *hostname, int s, int stype, unsigned char *context)
if (buf != NULL) if (buf != NULL)
OPENSSL_free(buf); OPENSSL_free(buf);
if (io != NULL) BIO_free_all(io);
BIO_free_all(io);
/* if (ssl_bio != NULL) BIO_free(ssl_bio);*/
return (ret); return (ret);
} }
@ -3159,8 +3151,7 @@ static int rev_body(char *hostname, int s, int stype, unsigned char *context)
if (buf != NULL) if (buf != NULL)
OPENSSL_free(buf); OPENSSL_free(buf);
if (io != NULL) BIO_free_all(io);
BIO_free_all(io);
return (ret); return (ret);
} }

View File

@ -237,8 +237,7 @@ int MAIN(int argc, char **argv)
} }
ret = 0; ret = 0;
end: end:
if (out != NULL) BIO_free_all(out);
BIO_free_all(out);
if (x != NULL) if (x != NULL)
SSL_SESSION_free(x); SSL_SESSION_free(x);
apps_shutdown(); apps_shutdown();
@ -279,7 +278,6 @@ static SSL_SESSION *load_sess_id(char *infile, int format)
} }
end: end:
if (in != NULL) BIO_free(in);
BIO_free(in);
return (x); return (x);
} }

View File

@ -162,8 +162,8 @@ int MAIN(int argc, char **argv)
apps_startup(); apps_startup();
if (bio_err == NULL && (bio_err = BIO_new(BIO_s_file())) != NULL) { 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); BIO_set_fp(bio_err, stderr, BIO_NOCLOSE | BIO_FP_TEXT);
free_bio_err = 1;
} }
if (!load_config(bio_err, NULL)) if (!load_config(bio_err, NULL))

View File

@ -650,8 +650,7 @@ static int multi_split(BIO *bio, char *bound, STACK_OF(BIO) **ret)
BIO_write(bpart, linebuf, len); BIO_write(bpart, linebuf, len);
} }
} }
if (bpart != NULL) BIO_free(bpart);
BIO_free(bpart);
return 0; return 0;
} }

View File

@ -179,8 +179,8 @@ static int asn1_bio_init(BIO_ASN1_BUF_CTX *ctx, int size)
static int asn1_bio_free(BIO *b) static int asn1_bio_free(BIO *b)
{ {
BIO_ASN1_BUF_CTX *ctx; BIO_ASN1_BUF_CTX *ctx = (BIO_ASN1_BUF_CTX *)b->ptr;
ctx = (BIO_ASN1_BUF_CTX *)b->ptr;
if (ctx == NULL) if (ctx == NULL)
return 0; return 0;
if (ctx->buf) if (ctx->buf)

View File

@ -142,8 +142,7 @@ BIO *BIO_new_NDEF(BIO *out, ASN1_VALUE *val, const ASN1_ITEM *it)
return sarg.ndef_bio; return sarg.ndef_bio;
err: err:
if (asn_bio) BIO_free(asn_bio);
BIO_free(asn_bio);
if (ndef_aux) if (ndef_aux)
OPENSSL_free(ndef_aux); OPENSSL_free(ndef_aux);
return NULL; return NULL;

View File

@ -549,8 +549,7 @@ BIO *BIO_dup_chain(BIO *in)
} }
return (ret); return (ret);
err: err:
if (ret != NULL) BIO_free(ret);
BIO_free(ret);
return (NULL); return (NULL);
} }

View File

@ -155,8 +155,7 @@ static void BIO_ACCEPT_free(BIO_ACCEPT *a)
OPENSSL_free(a->param_addr); OPENSSL_free(a->param_addr);
if (a->addr != NULL) if (a->addr != NULL)
OPENSSL_free(a->addr); OPENSSL_free(a->addr);
if (a->bio_chain != NULL) BIO_free(a->bio_chain);
BIO_free(a->bio_chain);
OPENSSL_free(a); OPENSSL_free(a);
} }
@ -360,8 +359,7 @@ static long acpt_ctrl(BIO *b, int cmd, long num, void *ptr)
} else if (num == 1) { } else if (num == 1) {
data->accept_nbio = (ptr != NULL); data->accept_nbio = (ptr != NULL);
} else if (num == 2) { } else if (num == 2) {
if (data->bio_chain != NULL) BIO_free(data->bio_chain);
BIO_free(data->bio_chain);
data->bio_chain = (BIO *)ptr; data->bio_chain = (BIO *)ptr;
} }
} }
@ -448,10 +446,8 @@ BIO *BIO_new_accept(const char *str)
return (NULL); return (NULL);
if (BIO_set_accept_port(ret, str)) if (BIO_set_accept_port(ret, str))
return (ret); return (ret);
else { BIO_free(ret);
BIO_free(ret); return (NULL);
return (NULL);
}
} }
#endif #endif

View File

@ -788,14 +788,10 @@ int BIO_new_bio_pair(BIO **bio1_p, size_t writebuf1,
err: err:
if (ret == 0) { if (ret == 0) {
if (bio1) { BIO_free(bio1);
BIO_free(bio1); bio1 = NULL;
bio1 = NULL; BIO_free(bio2);
} bio2 = NULL;
if (bio2) {
BIO_free(bio2);
bio2 = NULL;
}
} }
*bio1_p = bio1; *bio1_p = bio1;

View File

@ -588,10 +588,8 @@ BIO *BIO_new_connect(const char *str)
return (NULL); return (NULL);
if (BIO_set_conn_hostname(ret, str)) if (BIO_set_conn_hostname(ret, str))
return (ret); return (ret);
else { BIO_free(ret);
BIO_free(ret); return (NULL);
return (NULL);
}
} }
#endif #endif

View File

@ -354,8 +354,7 @@ BIO *cms_DigestAlgorithm_init_bio(X509_ALGOR *digestAlgorithm)
} }
return mdbio; return mdbio;
err: err:
if (mdbio) BIO_free(mdbio);
BIO_free(mdbio);
return NULL; return NULL;
} }

View File

@ -806,8 +806,7 @@ BIO *cms_SignedData_init_bio(CMS_ContentInfo *cms)
} }
return chain; return chain;
err: err:
if (chain) BIO_free_all(chain);
BIO_free_all(chain);
return NULL; return NULL;
} }

View File

@ -114,7 +114,7 @@ static int cms_copy_content(BIO *out, BIO *in, unsigned int flags)
r = 1; r = 1;
err: err:
if (tmpout && (tmpout != out)) if (tmpout != out)
BIO_free(tmpout); BIO_free(tmpout);
return r; return r;
@ -446,14 +446,13 @@ int CMS_verify(CMS_ContentInfo *cms, STACK_OF(X509) *certs,
if (tmpin != dcont) if (tmpin != dcont)
BIO_free(tmpin); BIO_free(tmpin);
} else { } else {
if (dcont && (tmpin == dcont)) if (dcont && (tmpin == dcont))
do_free_upto(cmsbio, dcont); do_free_upto(cmsbio, dcont);
else else
BIO_free_all(cmsbio); BIO_free_all(cmsbio);
} }
if (tmpout && out != tmpout) if (out != tmpout)
BIO_free_all(tmpout); BIO_free_all(tmpout);
if (cms_certs) if (cms_certs)
@ -580,8 +579,7 @@ CMS_ContentInfo *CMS_sign_receipt(CMS_SignerInfo *si,
r = 1; r = 1;
err: err:
if (rct_cont) BIO_free(rct_cont);
BIO_free(rct_cont);
if (r) if (r)
return cms; return cms;
CMS_ContentInfo_free(cms); CMS_ContentInfo_free(cms);

View File

@ -218,10 +218,8 @@ int main(int argc, char **argv)
ERR_remove_thread_state(NULL); ERR_remove_thread_state(NULL);
ERR_free_strings(); ERR_free_strings();
CRYPTO_mem_leaks(bio_err); CRYPTO_mem_leaks(bio_err);
if (bio_err != NULL) { BIO_free(bio_err);
BIO_free(bio_err); bio_err = NULL;
bio_err = NULL;
}
# ifdef OPENSSL_SYS_NETWARE # ifdef OPENSSL_SYS_NETWARE
if (!ret) if (!ret)
printf("ERROR\n"); printf("ERROR\n");

View File

@ -563,8 +563,7 @@ int main(void)
ERR_remove_thread_state(NULL); ERR_remove_thread_state(NULL);
ERR_free_strings(); ERR_free_strings();
CRYPTO_mem_leaks(out); CRYPTO_mem_leaks(out);
if (out != NULL) BIO_free(out);
BIO_free(out);
return ret; return ret;
} }
#endif #endif

View File

@ -136,8 +136,7 @@ OCSP_REQ_CTX *OCSP_REQ_CTX_new(BIO *io, int maxline)
void OCSP_REQ_CTX_free(OCSP_REQ_CTX *rctx) void OCSP_REQ_CTX_free(OCSP_REQ_CTX *rctx)
{ {
if (rctx->mem) BIO_free(rctx->mem);
BIO_free(rctx->mem);
if (rctx->iobuf) if (rctx->iobuf)
OPENSSL_free(rctx->iobuf); OPENSSL_free(rctx->iobuf);
OPENSSL_free(rctx); OPENSSL_free(rctx);

View File

@ -128,8 +128,7 @@ static int PKCS7_bio_add_digest(BIO **pbio, X509_ALGOR *alg)
return 1; return 1;
err: err:
if (btmp) BIO_free(btmp);
BIO_free(btmp);
return 0; return 0;
} }
@ -390,16 +389,12 @@ BIO *PKCS7_dataInit(PKCS7 *p7, BIO *bio)
BIO_push(out, bio); BIO_push(out, bio);
else else
out = bio; out = bio;
bio = NULL; return out;
if (0) {
err: err:
if (out != NULL) BIO_free_all(out);
BIO_free_all(out); BIO_free_all(btmp);
if (btmp != NULL) return NULL;
BIO_free_all(btmp);
out = NULL;
}
return (out);
} }
static int pkcs7_cmp_ri(PKCS7_RECIP_INFO *ri, X509 *pcert) 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_cleanse(tkey, tkeylen);
OPENSSL_free(tkey); OPENSSL_free(tkey);
} }
if (out != NULL) BIO_free_all(out);
BIO_free_all(out); BIO_free_all(btmp);
if (btmp != NULL) BIO_free_all(etmp);
BIO_free_all(btmp); BIO_free_all(bio);
if (etmp != NULL)
BIO_free_all(etmp);
if (bio != NULL)
BIO_free_all(bio);
out = NULL; out = NULL;
} }
return (out); return (out);

View File

@ -460,8 +460,7 @@ int SRP_VBASE_init(SRP_VBASE *vb, char *verifier_file)
if (tmpdb) if (tmpdb)
TXT_DB_free(tmpdb); TXT_DB_free(tmpdb);
if (in) BIO_free_all(in);
BIO_free_all(in);
sk_SRP_gN_free(SRP_gN_tab); sk_SRP_gN_free(SRP_gN_tab);

View File

@ -612,15 +612,11 @@ int doit(char *ctx[4])
} }
/* The SSL's are optionally freed in the following calls */ /* The SSL's are optionally freed in the following calls */
if (c_to_s != NULL) BIO_free(c_to_s);
BIO_free(c_to_s); BIO_free(s_to_c);
if (s_to_c != NULL)
BIO_free(s_to_c);
if (c_bio != NULL) BIO_free(c_bio);
BIO_free(c_bio); BIO_free(s_bio);
if (s_bio != NULL)
BIO_free(s_bio);
return (0); return (0);
} }

View File

@ -176,8 +176,7 @@ int X509_load_cert_file(X509_LOOKUP *ctx, const char *file, int type)
err: err:
if (x != NULL) if (x != NULL)
X509_free(x); X509_free(x);
if (in != NULL) BIO_free(in);
BIO_free(in);
return (ret); return (ret);
} }
@ -235,8 +234,7 @@ int X509_load_crl_file(X509_LOOKUP *ctx, const char *file, int type)
err: err:
if (x != NULL) if (x != NULL)
X509_CRL_free(x); X509_CRL_free(x);
if (in != NULL) BIO_free(in);
BIO_free(in);
return (ret); return (ret);
} }

View File

@ -243,13 +243,9 @@ char **argv;
OPENSSL_free(strbuf); OPENSSL_free(strbuf);
if (buff != NULL) if (buff != NULL)
OPENSSL_free(buff); OPENSSL_free(buff);
if (in != NULL) BIO_free(in);
BIO_free(in); BIO_free(out);
if (out != NULL) BIO_free(benc);
BIO_free(out); BIO_free(b64);
if (benc != NULL)
BIO_free(benc);
if (b64 != NULL)
BIO_free(b64);
EXIT(ret); EXIT(ret);
} }

View File

@ -22,8 +22,7 @@ BIO *in = NULL;
void close_up() void close_up()
{ {
if (in != NULL) BIO_free(in);
BIO_free(in);
} }
int main(int argc, char *argv[]) int main(int argc, char *argv[])
@ -101,8 +100,7 @@ int main(int argc, char *argv[])
if (ret) { if (ret) {
ERR_print_errors_fp(stderr); ERR_print_errors_fp(stderr);
} }
if (in != NULL) BIO_free(in);
BIO_free(in);
exit(ret); exit(ret);
return (!ret); return (!ret);
} }

View File

@ -137,8 +137,7 @@ int main(int argc, char *argv[])
if (ret) { if (ret) {
ERR_print_errors_fp(stderr); ERR_print_errors_fp(stderr);
} }
if (in != NULL) BIO_free(in);
BIO_free(in);
exit(ret); exit(ret);
return (!ret); return (!ret);
} }

View File

@ -131,8 +131,7 @@ int main(int argc, char *argv[])
if (ret) { if (ret) {
ERR_print_errors_fp(stderr); ERR_print_errors_fp(stderr);
} }
if (in != NULL) BIO_free(in);
BIO_free(in);
exit(ret); exit(ret);
return (!ret); return (!ret);
} }

View File

@ -50,10 +50,8 @@ int main(int argc, char **argv)
if (cms) if (cms)
CMS_ContentInfo_free(cms); CMS_ContentInfo_free(cms);
if (in) BIO_free(in);
BIO_free(in); BIO_free(out);
if (out)
BIO_free(out);
return ret; return ret;

View File

@ -75,14 +75,10 @@ int main(int argc, char **argv)
if (rkey) if (rkey)
EVP_PKEY_free(rkey); EVP_PKEY_free(rkey);
if (in) BIO_free(in);
BIO_free(in); BIO_free(out);
if (out) BIO_free(tbio);
BIO_free(out); BIO_free(dcont);
if (tbio)
BIO_free(tbio);
if (dcont)
BIO_free(dcont);
return ret; return ret;

View File

@ -66,12 +66,9 @@ int main(int argc, char **argv)
if (rkey) if (rkey)
EVP_PKEY_free(rkey); EVP_PKEY_free(rkey);
if (in) BIO_free(in);
BIO_free(in); BIO_free(out);
if (out) BIO_free(tbio);
BIO_free(out);
if (tbio)
BIO_free(tbio);
return ret; return ret;

View File

@ -84,14 +84,10 @@ int main(int argc, char **argv)
if (recips) if (recips)
sk_X509_pop_free(recips, X509_free); sk_X509_pop_free(recips, X509_free);
if (in) BIO_free(in);
BIO_free(in); BIO_free(out);
if (out) BIO_free(dout);
BIO_free(out); BIO_free(tbio);
if (dout)
BIO_free(dout);
if (tbio)
BIO_free(tbio);
return ret; return ret;

View File

@ -80,12 +80,9 @@ int main(int argc, char **argv)
if (recips) if (recips)
sk_X509_pop_free(recips, X509_free); sk_X509_pop_free(recips, X509_free);
if (in) BIO_free(in);
BIO_free(in); BIO_free(out);
if (out) BIO_free(tbio);
BIO_free(out);
if (tbio)
BIO_free(tbio);
return ret; return ret;

View File

@ -76,12 +76,9 @@ int main(int argc, char **argv)
if (skey) if (skey)
EVP_PKEY_free(skey); EVP_PKEY_free(skey);
if (in) BIO_free(in);
BIO_free(in); BIO_free(out);
if (out) BIO_free(tbio);
BIO_free(out);
if (tbio)
BIO_free(tbio);
return ret; return ret;

View File

@ -90,12 +90,9 @@ int main(int argc, char **argv)
if (skey) if (skey)
EVP_PKEY_free(skey2); EVP_PKEY_free(skey2);
if (in) BIO_free(in);
BIO_free(in); BIO_free(out);
if (out) BIO_free(tbio);
BIO_free(out);
if (tbio)
BIO_free(tbio);
return ret; return ret;

View File

@ -45,10 +45,8 @@ int main(int argc, char **argv)
if (cms) if (cms)
CMS_ContentInfo_free(cms); CMS_ContentInfo_free(cms);
if (in) BIO_free(in);
BIO_free(in); BIO_free(out);
if (out)
BIO_free(out);
return ret; return ret;

View File

@ -73,12 +73,9 @@ int main(int argc, char **argv)
if (cacert) if (cacert)
X509_free(cacert); X509_free(cacert);
if (in) BIO_free(in);
BIO_free(in); BIO_free(out);
if (out) BIO_free(tbio);
BIO_free(out);
if (tbio)
BIO_free(tbio);
return ret; return ret;

View File

@ -66,12 +66,9 @@ int main(int argc, char **argv)
if (rkey) if (rkey)
EVP_PKEY_free(rkey); EVP_PKEY_free(rkey);
if (in) BIO_free(in);
BIO_free(in); BIO_free(out);
if (out) BIO_free(tbio);
BIO_free(out);
if (tbio)
BIO_free(tbio);
return ret; return ret;

View File

@ -80,12 +80,9 @@ int main(int argc, char **argv)
if (recips) if (recips)
sk_X509_pop_free(recips, X509_free); sk_X509_pop_free(recips, X509_free);
if (in) BIO_free(in);
BIO_free(in); BIO_free(out);
if (out) BIO_free(tbio);
BIO_free(out);
if (tbio)
BIO_free(tbio);
return ret; return ret;

View File

@ -76,12 +76,9 @@ int main(int argc, char **argv)
if (skey) if (skey)
EVP_PKEY_free(skey); EVP_PKEY_free(skey);
if (in) BIO_free(in);
BIO_free(in); BIO_free(out);
if (out) BIO_free(tbio);
BIO_free(out);
if (tbio)
BIO_free(tbio);
return ret; return ret;

View File

@ -90,12 +90,9 @@ int main(int argc, char **argv)
if (skey) if (skey)
EVP_PKEY_free(skey2); EVP_PKEY_free(skey2);
if (in) BIO_free(in);
BIO_free(in); BIO_free(out);
if (out) BIO_free(tbio);
BIO_free(out);
if (tbio)
BIO_free(tbio);
return ret; return ret;

View File

@ -73,12 +73,9 @@ int main(int argc, char **argv)
if (cacert) if (cacert)
X509_free(cacert); X509_free(cacert);
if (in) BIO_free(in);
BIO_free(in); BIO_free(out);
if (out) BIO_free(tbio);
BIO_free(out);
if (tbio)
BIO_free(tbio);
return ret; return ret;

View File

@ -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_set() sets the method of an already existing BIO.
BIO_free() frees up a single BIO, BIO_vfree() also frees up a single 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 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 referred to under certain circumstances. For more details see the individual
BIO_METHOD descriptions. BIO_METHOD descriptions.
BIO_free_all() frees up an entire BIO chain, it does not halt if an error 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. occurs freeing up an individual BIO in the chain.
If B<a> is NULL nothing is done.
=head1 RETURN VALUES =head1 RETURN VALUES

View File

@ -656,8 +656,7 @@ static int hwcrhk_finish(ENGINE *e)
goto err; goto err;
} }
err: err:
if (logstream) BIO_free(logstream);
BIO_free(logstream);
hwcrhk_dso = NULL; hwcrhk_dso = NULL;
p_hwcrhk_Init = NULL; p_hwcrhk_Init = NULL;
p_hwcrhk_Finish = 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; BIO *bio = (BIO *)p;
CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
if (logstream) { BIO_free(logstream);
BIO_free(logstream); logstream = NULL;
logstream = NULL;
}
if (CRYPTO_add(&bio->references, 1, CRYPTO_LOCK_BIO) > 1) if (CRYPTO_add(&bio->references, 1, CRYPTO_LOCK_BIO) > 1)
logstream = bio; logstream = bio;
else else

View File

@ -404,10 +404,8 @@ static int surewarehk_ctrl(ENGINE *e, int cmd, long i, void *p,
{ {
BIO *bio = (BIO *)p; BIO *bio = (BIO *)p;
CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
if (logstream) { BIO_free(logstream);
BIO_free(logstream); logstream = NULL;
logstream = NULL;
}
if (CRYPTO_add(&bio->references, 1, CRYPTO_LOCK_BIO) > 1) if (CRYPTO_add(&bio->references, 1, CRYPTO_LOCK_BIO) > 1)
logstream = bio; logstream = bio;
else else
@ -596,8 +594,7 @@ static int surewarehk_finish(ENGINE *e)
goto err; goto err;
} }
err: err:
if (logstream) BIO_free(logstream);
BIO_free(logstream);
surewarehk_dso = NULL; surewarehk_dso = NULL;
p_surewarehk_Init = NULL; p_surewarehk_Init = NULL;
p_surewarehk_Finish = NULL; p_surewarehk_Finish = NULL;

View File

@ -503,10 +503,8 @@ BIO *BIO_new_buffer_ssl_connect(SSL_CTX *ctx)
goto err; goto err;
return (ret); return (ret);
err: err:
if (buf != NULL) BIO_free(buf);
BIO_free(buf); BIO_free(ssl);
if (ssl != NULL)
BIO_free(ssl);
#endif #endif
return (NULL); return (NULL);
} }
@ -524,8 +522,7 @@ BIO *BIO_new_ssl_connect(SSL_CTX *ctx)
goto err; goto err;
return (ret); return (ret);
err: err:
if (con != NULL) BIO_free(con);
BIO_free(con);
#endif #endif
return (NULL); return (NULL);
} }

View File

@ -558,8 +558,7 @@ int ssl3_enc(SSL *s, int send)
void ssl3_init_finished_mac(SSL *s) 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) if (s->s3->handshake_dgst)
ssl3_free_digest_list(s); ssl3_free_digest_list(s);
s->s3->handshake_buffer = BIO_new(BIO_s_mem()); s->s3->handshake_buffer = BIO_new(BIO_s_mem());

View File

@ -3147,9 +3147,7 @@ void ssl3_free(SSL *s)
if (s->s3->tmp.ca_names != NULL) if (s->s3->tmp.ca_names != NULL)
sk_X509_NAME_pop_free(s->s3->tmp.ca_names, X509_NAME_free); 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) if (s->s3->handshake_dgst)
ssl3_free_digest_list(s); ssl3_free_digest_list(s);
#ifndef OPENSSL_NO_TLSEXT #ifndef OPENSSL_NO_TLSEXT
@ -3200,10 +3198,8 @@ void ssl3_clear(SSL *s)
rlen = s->s3->rbuf.len; rlen = s->s3->rbuf.len;
wlen = s->s3->wbuf.len; wlen = s->s3->wbuf.len;
init_extra = s->s3->init_extra; init_extra = s->s3->init_extra;
if (s->s3->handshake_buffer) { BIO_free(s->s3->handshake_buffer);
BIO_free(s->s3->handshake_buffer); s->s3->handshake_buffer = NULL;
s->s3->handshake_buffer = NULL;
}
if (s->s3->handshake_dgst) { if (s->s3->handshake_dgst) {
ssl3_free_digest_list(s); ssl3_free_digest_list(s);
} }

View File

@ -877,8 +877,7 @@ STACK_OF(X509_NAME) *SSL_load_client_CA_file(const char *file)
} }
if (sk != NULL) if (sk != NULL)
sk_X509_NAME_free(sk); sk_X509_NAME_free(sk);
if (in != NULL) BIO_free(in);
BIO_free(in);
if (x != NULL) if (x != NULL)
X509_free(x); X509_free(x);
if (ret != NULL) if (ret != NULL)
@ -938,8 +937,7 @@ int SSL_add_file_cert_subjects_to_stack(STACK_OF(X509_NAME) *stack,
err: err:
ret = 0; ret = 0;
} }
if (in != NULL) BIO_free(in);
BIO_free(in);
if (x != NULL) if (x != NULL)
X509_free(x); X509_free(x);

View File

@ -438,8 +438,7 @@ static int cmd_DHParameters(SSL_CONF_CTX *cctx, const char *value)
rv = SSL_set_tmp_dh(cctx->ssl, dh); rv = SSL_set_tmp_dh(cctx->ssl, dh);
end: end:
DH_free(dh); DH_free(dh);
if (in) BIO_free(in);
BIO_free(in);
return rv > 0; return rv > 0;
} }
#endif #endif

View File

@ -543,9 +543,8 @@ void SSL_free(SSL *s)
BIO_free(s->bbio); BIO_free(s->bbio);
s->bbio = NULL; s->bbio = NULL;
} }
if (s->rbio != NULL) BIO_free_all(s->rbio);
BIO_free_all(s->rbio); if (s->wbio != s->rbio)
if ((s->wbio != NULL) && (s->wbio != s->rbio))
BIO_free_all(s->wbio); BIO_free_all(s->wbio);
if (s->init_buf != NULL) if (s->init_buf != NULL)
@ -621,7 +620,7 @@ void SSL_free(SSL *s)
void SSL_set_rbio(SSL *s, BIO *rbio) void SSL_set_rbio(SSL *s, BIO *rbio)
{ {
if ((s->rbio != NULL) && (s->rbio != rbio)) if (s->rbio != rbio)
BIO_free_all(s->rbio); BIO_free_all(s->rbio);
s->rbio = rbio; s->rbio = rbio;
} }
@ -637,7 +636,7 @@ void SSL_set_wbio(SSL *s, BIO *wbio)
s->bbio->next_bio = NULL; 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); BIO_free_all(s->wbio);
s->wbio = wbio; s->wbio = wbio;
} }

View File

@ -121,8 +121,7 @@ int SSL_use_certificate_file(SSL *ssl, const char *file, int type)
end: end:
if (x != NULL) if (x != NULL)
X509_free(x); X509_free(x);
if (in != NULL) BIO_free(in);
BIO_free(in);
return (ret); return (ret);
} }
#endif #endif
@ -262,8 +261,7 @@ int SSL_use_RSAPrivateKey_file(SSL *ssl, const char *file, int type)
ret = SSL_use_RSAPrivateKey(ssl, rsa); ret = SSL_use_RSAPrivateKey(ssl, rsa);
RSA_free(rsa); RSA_free(rsa);
end: end:
if (in != NULL) BIO_free(in);
BIO_free(in);
return (ret); return (ret);
} }
# endif # endif
@ -335,8 +333,7 @@ int SSL_use_PrivateKey_file(SSL *ssl, const char *file, int type)
ret = SSL_use_PrivateKey(ssl, pkey); ret = SSL_use_PrivateKey(ssl, pkey);
EVP_PKEY_free(pkey); EVP_PKEY_free(pkey);
end: end:
if (in != NULL) BIO_free(in);
BIO_free(in);
return (ret); return (ret);
} }
#endif #endif
@ -470,8 +467,7 @@ int SSL_CTX_use_certificate_file(SSL_CTX *ctx, const char *file, int type)
end: end:
if (x != NULL) if (x != NULL)
X509_free(x); X509_free(x);
if (in != NULL) BIO_free(in);
BIO_free(in);
return (ret); return (ret);
} }
#endif #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); ret = SSL_CTX_use_RSAPrivateKey(ctx, rsa);
RSA_free(rsa); RSA_free(rsa);
end: end:
if (in != NULL) BIO_free(in);
BIO_free(in);
return (ret); return (ret);
} }
# endif # 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); ret = SSL_CTX_use_PrivateKey(ctx, pkey);
EVP_PKEY_free(pkey); EVP_PKEY_free(pkey);
end: end:
if (in != NULL) BIO_free(in);
BIO_free(in);
return (ret); return (ret);
} }
#endif #endif
@ -726,8 +720,7 @@ int SSL_CTX_use_certificate_chain_file(SSL_CTX *ctx, const char *file)
end: end:
if (x != NULL) if (x != NULL)
X509_free(x); X509_free(x);
if (in != NULL) BIO_free(in);
BIO_free(in);
return (ret); return (ret);
} }
#endif #endif
@ -991,8 +984,7 @@ int SSL_CTX_use_serverinfo_file(SSL_CTX *ctx, const char *file)
OPENSSL_free(header); OPENSSL_free(header);
OPENSSL_free(extension); OPENSSL_free(extension);
OPENSSL_free(serverinfo); OPENSSL_free(serverinfo);
if (bin != NULL) BIO_free(bin);
BIO_free(bin);
return ret; return ret;
} }
# endif /* OPENSSL_NO_STDIO */ # endif /* OPENSSL_NO_STDIO */

View File

@ -381,13 +381,9 @@ int doit(io_channel chan, SSL_CTX *s_ctx)
s_ssl->rbio = NULL; s_ssl->rbio = NULL;
s_ssl->wbio = NULL; s_ssl->wbio = NULL;
if (c_to_s != NULL) BIO_free(c_to_s);
BIO_free(c_to_s); BIO_free(s_to_c);
if (s_to_c != NULL) BIO_free(c_bio);
BIO_free(s_to_c); BIO_free(s_bio);
if (c_bio != NULL)
BIO_free(c_bio);
if (s_bio != NULL)
BIO_free(s_bio);
return (0); return (0);
} }

View File

@ -1798,8 +1798,7 @@ int main(int argc, char *argv[])
SSL_CONF_CTX_free(c_cctx); SSL_CONF_CTX_free(c_cctx);
sk_OPENSSL_STRING_free(conf_args); sk_OPENSSL_STRING_free(conf_args);
if (bio_stdout != NULL) BIO_free(bio_stdout);
BIO_free(bio_stdout);
#ifndef OPENSSL_NO_RSA #ifndef OPENSSL_NO_RSA
free_tmp_rsa(); free_tmp_rsa();
@ -1812,8 +1811,7 @@ int main(int argc, char *argv[])
ERR_remove_thread_state(NULL); ERR_remove_thread_state(NULL);
EVP_cleanup(); EVP_cleanup();
CRYPTO_mem_leaks(bio_err); CRYPTO_mem_leaks(bio_err);
if (bio_err != NULL) BIO_free(bio_err);
BIO_free(bio_err);
EXIT(ret); EXIT(ret);
} }
@ -2173,18 +2171,12 @@ int doit_biopair(SSL *s_ssl, SSL *c_ssl, long count,
err: err:
ERR_print_errors(bio_err); ERR_print_errors(bio_err);
if (server) BIO_free(server);
BIO_free(server); BIO_free(server_io);
if (server_io) BIO_free(client);
BIO_free(server_io); BIO_free(client_io);
if (client) BIO_free(s_ssl_bio);
BIO_free(client); BIO_free(c_ssl_bio);
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);
return ret; return ret;
} }
@ -2468,14 +2460,10 @@ int doit(SSL *s_ssl, SSL *c_ssl, long count)
c_ssl->wbio = NULL; c_ssl->wbio = NULL;
} }
if (c_to_s != NULL) BIO_free(c_to_s);
BIO_free(c_to_s); BIO_free(s_to_c);
if (s_to_c != NULL) BIO_free_all(c_bio);
BIO_free(s_to_c); BIO_free_all(s_bio);
if (c_bio != NULL)
BIO_free_all(c_bio);
if (s_bio != NULL)
BIO_free_all(s_bio);
if (cbuf) if (cbuf)
OPENSSL_free(cbuf); OPENSSL_free(cbuf);