From 62b76bf39e3e7bf9622a00d66ca7aca9fe2404d1 Mon Sep 17 00:00:00 2001 From: SakiTakamachi Date: Fri, 27 Jun 2025 20:34:09 +0900 Subject: [PATCH 1/4] Decrease the reference count before calling `zend_list_close()` --- ext/oci8/oci8.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/ext/oci8/oci8.c b/ext/oci8/oci8.c index 01cb1c8ad9277..a849c60488c00 100644 --- a/ext/oci8/oci8.c +++ b/ext/oci8/oci8.c @@ -573,12 +573,8 @@ void php_oci_column_hash_dtor(zval *data) zend_list_close(column->stmtid); } - if (column->descid) { - if (GC_REFCOUNT(column->descid) == 1) - zend_list_close(column->descid); - else { - GC_DELREF(column->descid); - } + if (column->descid && !GC_DELREF(column->descid)) { + zend_list_close(column->descid); } if (column->data) { From eeaac90b58f3715d2c9d7c95235118b7ee13b153 Mon Sep 17 00:00:00 2001 From: SakiTakamachi Date: Mon, 30 Jun 2025 12:44:38 +0900 Subject: [PATCH 2/4] Address comments --- ext/oci8/oci8.c | 2 +- ext/oci8/tests/gh18873.phpt | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 ext/oci8/tests/gh18873.phpt diff --git a/ext/oci8/oci8.c b/ext/oci8/oci8.c index a849c60488c00..b13843e866665 100644 --- a/ext/oci8/oci8.c +++ b/ext/oci8/oci8.c @@ -574,7 +574,7 @@ void php_oci_column_hash_dtor(zval *data) } if (column->descid && !GC_DELREF(column->descid)) { - zend_list_close(column->descid); + zend_list_free(column->descid); } if (column->data) { diff --git a/ext/oci8/tests/gh18873.phpt b/ext/oci8/tests/gh18873.phpt new file mode 100644 index 0000000000000..a1154330c40cb --- /dev/null +++ b/ext/oci8/tests/gh18873.phpt @@ -0,0 +1,37 @@ +--TEST-- +GH-18873 (OCI_RETURN_LOBS flag causes oci8 to leak memory) +--EXTENSIONS-- +oci8 +--SKIPIF-- + +--FILE-- + +--EXPECT-- +Done! From 6c139b7e4f1b20c397f3918322da1386a67cbb65 Mon Sep 17 00:00:00 2001 From: SakiTakamachi Date: Tue, 1 Jul 2025 10:40:38 +0900 Subject: [PATCH 3/4] Skip the test when Zend MM is disabled. --- ext/oci8/tests/gh18873.phpt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ext/oci8/tests/gh18873.phpt b/ext/oci8/tests/gh18873.phpt index a1154330c40cb..76e8258cacb2c 100644 --- a/ext/oci8/tests/gh18873.phpt +++ b/ext/oci8/tests/gh18873.phpt @@ -5,6 +5,14 @@ oci8 --SKIPIF-- enabled') === false) { + die('skip Zend MM is disabled'); +} ?> --FILE-- Date: Wed, 2 Jul 2025 12:17:21 +0900 Subject: [PATCH 4/4] fixed the skip condition --- ext/oci8/tests/gh18873.phpt | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/ext/oci8/tests/gh18873.phpt b/ext/oci8/tests/gh18873.phpt index 76e8258cacb2c..acd88facb57c1 100644 --- a/ext/oci8/tests/gh18873.phpt +++ b/ext/oci8/tests/gh18873.phpt @@ -5,14 +5,7 @@ oci8 --SKIPIF-- enabled') === false) { - die('skip Zend MM is disabled'); -} +if (getenv("USE_ZEND_ALLOC") === "0") die("skip requires ZendMM"); ?> --FILE--