Skip to content

Commit 337973f

Browse files
committed
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1: Fix GH-8979: Possible Memory Leak with SSL-enabled MySQL connections
2 parents 8a25862 + 8930bf8 commit 337973f

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ PHP NEWS
3535
. Fixed bug GH-10521 (ftp_get/ftp_nb_get resumepos offset is maximum 10GB).
3636
(nielsdos)
3737

38+
- MySQLnd:
39+
. Fixed bug GH-8979 (Possible Memory Leak with SSL-enabled MySQL
40+
connections). (nielsdos)
41+
3842
- Opcache:
3943
. Fixed build for macOS to cater with pkg-config settings. (David Carlier)
4044
. Fixed bug GH-8065 (opcache.consistency_checks > 0 causes segfaults in

ext/mysqlnd/mysqlnd_vio.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,10 @@ MYSQLND_METHOD(mysqlnd_vio, enable_ssl)(MYSQLND_VIO * const net)
561561
}
562562
}
563563
php_stream_context_set(net_stream, context);
564+
/* php_stream_context_set() increases the refcount of context, but we just want to transfer ownership
565+
* hence the need to decrease the refcount so the refcount will be equal to 1. */
566+
ZEND_ASSERT(GC_REFCOUNT(context->res) == 2);
567+
GC_DELREF(context->res);
564568
if (php_stream_xport_crypto_setup(net_stream, STREAM_CRYPTO_METHOD_TLS_CLIENT, NULL) < 0 ||
565569
php_stream_xport_crypto_enable(net_stream, 1) < 0)
566570
{

0 commit comments

Comments
 (0)