From e30dd20c0ec57b96c31aa3ffea9f646aa32368ba Mon Sep 17 00:00:00 2001 From: "Dr. Stephen Henson" Date: Thu, 25 Jun 2009 11:29:30 +0000 Subject: Update from 1.0.0-stable --- ssl/bio_ssl.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'ssl/bio_ssl.c') diff --git a/ssl/bio_ssl.c b/ssl/bio_ssl.c index da6dfd2262..af319af302 100644 --- a/ssl/bio_ssl.c +++ b/ssl/bio_ssl.c @@ -398,17 +398,19 @@ static long ssl_ctrl(BIO *b, int cmd, long num, void *ptr) } break; case BIO_CTRL_POP: - /* ugly bit of a hack */ - if (ssl->rbio != ssl->wbio) /* we are in trouble :-( */ + /* Only detach if we are the BIO explicitly being popped */ + if (b == ptr) { - BIO_free_all(ssl->wbio); - } - if (b->next_bio != NULL) - { - CRYPTO_add(&b->next_bio->references,1,CRYPTO_LOCK_BIO); + /* Shouldn't happen in practice because the + * rbio and wbio are the same when pushed. + */ + if (ssl->rbio != ssl->wbio) + BIO_free_all(ssl->wbio); + if (b->next_bio != NULL) + CRYPTO_add(&b->next_bio->references,-1,CRYPTO_LOCK_BIO); + ssl->wbio=NULL; + ssl->rbio=NULL; } - ssl->wbio=NULL; - ssl->rbio=NULL; break; case BIO_C_DO_STATE_MACHINE: BIO_clear_retry_flags(b); -- cgit v1.2.3