X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=blobdiff_plain;f=crypto%2Fbio%2Fbio_lib.c;h=cc859da74012e25adb220c9d75dfd4e1e181e29b;hp=5267010cb0d7ff51230e49c34bd72328f8ffe8b7;hb=aec54108ef0d469964505ac1f77984f19099ec05;hpb=0f113f3ee4d629ef9a4a30911b22b224772085e5 diff --git a/crypto/bio/bio_lib.c b/crypto/bio/bio_lib.c index 5267010cb0..cc859da740 100644 --- a/crypto/bio/bio_lib.c +++ b/crypto/bio/bio_lib.c @@ -59,15 +59,14 @@ #include #include #include -#include "cryptlib.h" +#include "internal/cryptlib.h" #include #include BIO *BIO_new(BIO_METHOD *method) { - BIO *ret = NULL; + BIO *ret = OPENSSL_malloc(sizeof(*ret)); - ret = (BIO *)OPENSSL_malloc(sizeof(BIO)); if (ret == NULL) { BIOerr(BIO_F_BIO_NEW, ERR_R_MALLOC_FAILURE); return (NULL); @@ -536,8 +535,10 @@ BIO *BIO_dup_chain(BIO *in) /* copy app data */ if (!CRYPTO_dup_ex_data(CRYPTO_EX_INDEX_BIO, &new_bio->ex_data, - &bio->ex_data)) + &bio->ex_data)) { + BIO_free(new_bio); goto err; + } if (ret == NULL) { eoc = new_bio; @@ -549,8 +550,8 @@ BIO *BIO_dup_chain(BIO *in) } return (ret); err: - if (ret != NULL) - BIO_free(ret); + BIO_free_all(ret); + return (NULL); } @@ -590,5 +591,3 @@ unsigned long BIO_number_written(BIO *bio) return bio->num_write; return 0; } - -IMPLEMENT_STACK_OF(BIO)