Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions ext/oci8/oci8.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
37 changes: 37 additions & 0 deletions ext/oci8/tests/gh18873.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
--TEST--
GH-18873 (OCI_RETURN_LOBS flag causes oci8 to leak memory)
--EXTENSIONS--
oci8
--SKIPIF--
<?php
require_once 'skipifconnectfailure.inc';
?>
--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!
Loading