Skip to content

Commit 7b133e0

Browse files
committed
Merge branch 'PHP-7.0' into PHP-7.1
2 parents 898e439 + ac1372d commit 7b133e0

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

ext/openssl/xp_ssl.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1568,8 +1568,8 @@ int php_openssl_setup_crypto(php_stream *stream,
15681568
if (sslsock->is_client) {
15691569
SSL_CTX_set_alpn_protos(sslsock->ctx, alpn, alpn_len);
15701570
} 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));
15731573
sslsock->alpn_ctx->len = alpn_len;
15741574
SSL_CTX_set_alpn_select_cb(sslsock->ctx, server_alpn_callback, sslsock);
15751575
}
@@ -1601,6 +1601,13 @@ int php_openssl_setup_crypto(php_stream *stream,
16011601
php_error_docref(NULL, E_WARNING, "SSL handle creation failure");
16021602
SSL_CTX_free(sslsock->ctx);
16031603
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
16041611
return FAILURE;
16051612
} else {
16061613
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) /* {{{
21022109
SSL_CTX_free(sslsock->ctx);
21032110
sslsock->ctx = NULL;
21042111
}
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
21052118
#ifdef PHP_WIN32
21062119
if (sslsock->s.socket == -1)
21072120
sslsock->s.socket = SOCK_ERR;

0 commit comments

Comments
 (0)