summaryrefslogtreecommitdiff
path: root/src/lib/libssl/bio_ssl.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libssl/bio_ssl.c')
-rw-r--r--src/lib/libssl/bio_ssl.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/lib/libssl/bio_ssl.c b/src/lib/libssl/bio_ssl.c
index 420deb7fc9..af319af302 100644
--- a/src/lib/libssl/bio_ssl.c
+++ b/src/lib/libssl/bio_ssl.c
@@ -398,17 +398,19 @@ static long ssl_ctrl(BIO *b, int cmd, long num, void *ptr)
398 } 398 }
399 break; 399 break;
400 case BIO_CTRL_POP: 400 case BIO_CTRL_POP:
401 /* ugly bit of a hack */ 401 /* Only detach if we are the BIO explicitly being popped */
402 if (ssl->rbio != ssl->wbio) /* we are in trouble :-( */ 402 if (b == ptr)
403 { 403 {
404 BIO_free_all(ssl->wbio); 404 /* Shouldn't happen in practice because the
405 } 405 * rbio and wbio are the same when pushed.
406 if (b->next_bio != NULL) 406 */
407 { 407 if (ssl->rbio != ssl->wbio)
408 CRYPTO_add(&b->next_bio->references,1,CRYPTO_LOCK_BIO); 408 BIO_free_all(ssl->wbio);
409 if (b->next_bio != NULL)
410 CRYPTO_add(&b->next_bio->references,-1,CRYPTO_LOCK_BIO);
411 ssl->wbio=NULL;
412 ssl->rbio=NULL;
409 } 413 }
410 ssl->wbio=NULL;
411 ssl->rbio=NULL;
412 break; 414 break;
413 case BIO_C_DO_STATE_MACHINE: 415 case BIO_C_DO_STATE_MACHINE:
414 BIO_clear_retry_flags(b); 416 BIO_clear_retry_flags(b);
@@ -543,7 +545,6 @@ BIO *BIO_new_ssl_connect(SSL_CTX *ctx)
543 return(ret); 545 return(ret);
544err: 546err:
545 if (con != NULL) BIO_free(con); 547 if (con != NULL) BIO_free(con);
546 if (ret != NULL) BIO_free(ret);
547 return(NULL); 548 return(NULL);
548 } 549 }
549 550