1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Fix GH-18873 - Free column->descid appropriately (#18957)

fixes #18873
closes #18957
This commit is contained in:
SakiTakamachi
2025-06-27 20:34:09 +09:00
committed by Saki Takamachi
parent 69328ba304
commit c161bb0c18
3 changed files with 44 additions and 6 deletions

4
NEWS
View File

@@ -22,6 +22,10 @@ PHP NEWS
- MbString:
. Fixed bug GH-18901 (integer overflow mb_split). (nielsdos)
- OCI8:
. Fixed bug GH-18873 (OCI_RETURN_LOBS flag causes oci8 to leak memory).
(Saki Takamachi)
- Opcache:
. Fixed bug GH-18639 (Internal class aliases can break preloading + JIT).
(nielsdos)

View File

@@ -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_free(column->descid);
}
if (column->data) {

View File

@@ -0,0 +1,38 @@
--TEST--
GH-18873 (OCI_RETURN_LOBS flag causes oci8 to leak memory)
--EXTENSIONS--
oci8
--SKIPIF--
<?php
require_once 'skipifconnectfailure.inc';
if (getenv("USE_ZEND_ALLOC") === "0") die("skip requires ZendMM");
?>
--FILE--
<?php
require __DIR__.'/connect.inc';
$expectedStr = str_repeat('a', 1_001);
$sql = 'select concat(TO_CLOB(\'' . str_repeat('a', 1_000) . '\'), TO_CLOB(\'a\')) AS "v" from "DUAL"';
$memUsages = array_flip(range(0, 100 - 1));
foreach (array_keys($memUsages) as $k) {
$stid = oci_parse($c, $sql);
oci_execute($stid);
$row = oci_fetch_array($stid, \OCI_ASSOC | \OCI_RETURN_LOBS);
$res = $row['v'];
$memUsages[$k] = memory_get_usage();
}
$memUsages = array_slice($memUsages, 1, null, true);
$memUsages = array_unique($memUsages);
if (count($memUsages) !== 1) {
var_dump($memUsages);
throw new \Exception('memory leak detected');
}
echo "Done!\n";
?>
--EXPECT--
Done!