app_http_tls_cb: Fix double-free in case TLS not used
@@ -2464,9 +2464,10 @@ static const char *tls_error_hint(void)
/* HTTP callback function that supports TLS connection also via HTTPS proxy */
BIO *app_http_tls_cb(BIO *bio, void *arg, int connect, int detail)
{
- if (connect && detail) { /* connecting with TLS */
APP_HTTP_TLS_INFO *info = (APP_HTTP_TLS_INFO *)arg;
SSL_CTX *ssl_ctx = info->ssl_ctx;
+
+ if (connect && detail) { /* connecting with TLS */
SSL *ssl;
BIO *sbio = NULL;
@@ -2500,6 +2501,7 @@ BIO *app_http_tls_cb(BIO *bio, void *arg, int connect, int detail)
if (hint != NULL)
ERR_add_error_data(2, " : ", hint);
}
+ if (ssl_ctx != NULL) {
(void)ERR_set_mark();
BIO_ssl_shutdown(bio);
cbio = BIO_pop(bio); /* connect+HTTP BIO */
@@ -2507,6 +2509,7 @@ BIO *app_http_tls_cb(BIO *bio, void *arg, int connect, int detail)
(void)ERR_pop_to_mark(); /* hide SSL_R_READ_BIO_NOT_SET etc. */
bio = cbio;
}
+ }
return bio;
}
