@@ -1599,8 +1599,8 @@ int php_openssl_setup_crypto(php_stream *stream,
1599
1599
if (sslsock -> is_client ) {
1600
1600
SSL_CTX_set_alpn_protos (sslsock -> ctx , alpn , alpn_len );
1601
1601
} else {
1602
- sslsock -> alpn_ctx = (php_openssl_alpn_ctx * ) emalloc (sizeof (php_openssl_alpn_ctx ));
1603
- sslsock -> alpn_ctx -> data = (unsigned char * ) estrndup ((const char * )alpn , alpn_len );
1602
+ sslsock -> alpn_ctx = (php_openssl_alpn_ctx * ) pemalloc (sizeof (php_openssl_alpn_ctx ), php_stream_is_persistent ( stream ));
1603
+ sslsock -> alpn_ctx -> data = (unsigned char * ) pestrndup ((const char * )alpn , alpn_len , php_stream_is_persistent ( stream ) );
1604
1604
sslsock -> alpn_ctx -> len = alpn_len ;
1605
1605
SSL_CTX_set_alpn_select_cb (sslsock -> ctx , server_alpn_callback , sslsock );
1606
1606
}
@@ -1632,6 +1632,13 @@ int php_openssl_setup_crypto(php_stream *stream,
1632
1632
php_error_docref (NULL , E_WARNING , "SSL handle creation failure" );
1633
1633
SSL_CTX_free (sslsock -> ctx );
1634
1634
sslsock -> ctx = NULL ;
1635
+ #ifdef HAVE_TLS_ALPN
1636
+ if (sslsock -> alpn_ctx ) {
1637
+ pefree (sslsock -> alpn_ctx -> data , php_stream_is_persistent (stream ));
1638
+ pefree (sslsock -> alpn_ctx , php_stream_is_persistent (stream ));
1639
+ sslsock -> alpn_ctx = NULL ;
1640
+ }
1641
+ #endif
1635
1642
return FAILURE ;
1636
1643
} else {
1637
1644
SSL_set_ex_data (sslsock -> ssl_handle , php_openssl_get_ssl_stream_data_index (), stream );
@@ -2137,6 +2144,12 @@ static int php_openssl_sockop_close(php_stream *stream, int close_handle) /* {{{
2137
2144
SSL_CTX_free (sslsock -> ctx );
2138
2145
sslsock -> ctx = NULL ;
2139
2146
}
2147
+ #ifdef HAVE_TLS_ALPN
2148
+ if (sslsock -> alpn_ctx ) {
2149
+ pefree (sslsock -> alpn_ctx -> data , php_stream_is_persistent (stream ));
2150
+ pefree (sslsock -> alpn_ctx , php_stream_is_persistent (stream ));
2151
+ }
2152
+ #endif
2140
2153
#ifdef PHP_WIN32
2141
2154
if (sslsock -> s .socket == -1 )
2142
2155
sslsock -> s .socket = SOCK_ERR ;
0 commit comments