X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=crypto%2Fbio%2Fbio_lib.c;h=381afc9b8e03a05d5e8b3459e5a3d9facc4b5055;hb=7d09713d09f41778c92913d57a877a4eb1aebbfc;hp=77e43763cb041267fd1d1f857916797d6fddb013;hpb=371acb22e68ff23128485ce134a9931de889e719;p=oweals%2Fopenssl.git diff --git a/crypto/bio/bio_lib.c b/crypto/bio/bio_lib.c index 77e43763cb..381afc9b8e 100644 --- a/crypto/bio/bio_lib.c +++ b/crypto/bio/bio_lib.c @@ -70,7 +70,7 @@ BIO *BIO_new(BIO_METHOD *method) { BIO *ret=NULL; - ret=(BIO *)Malloc(sizeof(BIO)); + ret=(BIO *)OPENSSL_malloc(sizeof(BIO)); if (ret == NULL) { BIOerr(BIO_F_BIO_NEW,ERR_R_MALLOC_FAILURE); @@ -78,7 +78,7 @@ BIO *BIO_new(BIO_METHOD *method) } if (!BIO_set(ret,method)) { - Free(ret); + OPENSSL_free(ret); ret=NULL; } return(ret); @@ -133,7 +133,7 @@ int BIO_free(BIO *a) if ((a->method == NULL) || (a->method->destroy == NULL)) return(1); ret=a->method->destroy(a); - Free(a); + OPENSSL_free(a); return(1); } @@ -201,13 +201,7 @@ int BIO_write(BIO *b, const void *in, int inl) if (i > 0) b->num_write+=(unsigned long)i; - /* This is evil and not thread safe. If the BIO has been freed, - * we must not call the callback. The only way to be able to - * determine this is the reference count which is now invalid since - * the memory has been free()ed. - */ - if (b->references <= 0) abort(); - if (cb != NULL) /* && (b->references >= 1)) */ + if (cb != NULL) i=(int)cb(b,BIO_CB_WRITE|BIO_CB_RETURN,in,inl, 0L,(long)i); return(i); @@ -238,6 +232,8 @@ int BIO_puts(BIO *b, const char *in) i=b->method->bputs(b,in); + if (i > 0) b->num_write+=(unsigned long)i; + if (cb != NULL) i=(int)cb(b,BIO_CB_PUTS|BIO_CB_RETURN,in,0, 0L,(long)i); @@ -422,6 +418,7 @@ BIO *BIO_find_type(BIO *bio, int type) { int mt,mask; + if(!bio) return NULL; mask=type&0xff; do { if (bio->method != NULL) @@ -440,6 +437,12 @@ BIO *BIO_find_type(BIO *bio, int type) return(NULL); } +BIO *BIO_next(BIO *b) + { + if(!b) return NULL; + return b->next_bio; + } + void BIO_free_all(BIO *bio) { BIO *b;