@@ -1568,8 +1568,8 @@ int php_openssl_setup_crypto(php_stream *stream,
1568
1568
if (sslsock -> is_client ) {
1569
1569
SSL_CTX_set_alpn_protos (sslsock -> ctx , alpn , alpn_len );
1570
1570
} else {
1571
- sslsock -> alpn_ctx = (php_openssl_alpn_ctx * ) emalloc (sizeof (php_openssl_alpn_ctx ));
1572
- sslsock -> alpn_ctx -> data = (unsigned char * ) estrndup ((const char * )alpn , alpn_len );
1571
+ sslsock -> alpn_ctx = (php_openssl_alpn_ctx * ) pemalloc (sizeof (php_openssl_alpn_ctx ), php_stream_is_persistent ( stream ));
1572
+ sslsock -> alpn_ctx -> data = (unsigned char * ) pestrndup ((const char * )alpn , alpn_len , php_stream_is_persistent ( stream ) );
1573
1573
sslsock -> alpn_ctx -> len = alpn_len ;
1574
1574
SSL_CTX_set_alpn_select_cb (sslsock -> ctx , server_alpn_callback , sslsock );
1575
1575
}
@@ -1601,6 +1601,13 @@ int php_openssl_setup_crypto(php_stream *stream,
1601
1601
php_error_docref (NULL , E_WARNING , "SSL handle creation failure" );
1602
1602
SSL_CTX_free (sslsock -> ctx );
1603
1603
sslsock -> ctx = NULL ;
1604
+ #ifdef HAVE_TLS_ALPN
1605
+ if (sslsock -> alpn_ctx ) {
1606
+ pefree (sslsock -> alpn_ctx -> data , php_stream_is_persistent (stream ));
1607
+ pefree (sslsock -> alpn_ctx , php_stream_is_persistent (stream ));
1608
+ sslsock -> alpn_ctx = NULL ;
1609
+ }
1610
+ #endif
1604
1611
return FAILURE ;
1605
1612
} else {
1606
1613
SSL_set_ex_data (sslsock -> ssl_handle , php_openssl_get_ssl_stream_data_index (), stream );
@@ -2102,6 +2109,12 @@ static int php_openssl_sockop_close(php_stream *stream, int close_handle) /* {{{
2102
2109
SSL_CTX_free (sslsock -> ctx );
2103
2110
sslsock -> ctx = NULL ;
2104
2111
}
2112
+ #ifdef HAVE_TLS_ALPN
2113
+ if (sslsock -> alpn_ctx ) {
2114
+ pefree (sslsock -> alpn_ctx -> data , php_stream_is_persistent (stream ));
2115
+ pefree (sslsock -> alpn_ctx , php_stream_is_persistent (stream ));
2116
+ }
2117
+ #endif
2105
2118
#ifdef PHP_WIN32
2106
2119
if (sslsock -> s .socket == -1 )
2107
2120
sslsock -> s .socket = SOCK_ERR ;
0 commit comments