Skip to content

Commit eeaac90

Browse files
committed
Address comments
1 parent 62b76bf commit eeaac90

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

ext/oci8/oci8.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ void php_oci_column_hash_dtor(zval *data)
574574
}
575575

576576
if (column->descid && !GC_DELREF(column->descid)) {
577-
zend_list_close(column->descid);
577+
zend_list_free(column->descid);
578578
}
579579

580580
if (column->data) {

ext/oci8/tests/gh18873.phpt

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
--TEST--
2+
GH-18873 (OCI_RETURN_LOBS flag causes oci8 to leak memory)
3+
--EXTENSIONS--
4+
oci8
5+
--SKIPIF--
6+
<?php
7+
require_once 'skipifconnectfailure.inc';
8+
?>
9+
--FILE--
10+
<?php
11+
require __DIR__.'/connect.inc';
12+
13+
$expectedStr = str_repeat('a', 1_001);
14+
$sql = 'select concat(TO_CLOB(\'' . str_repeat('a', 1_000) . '\'), TO_CLOB(\'a\')) AS "v" from "DUAL"';
15+
16+
$memUsages = array_flip(range(0, 100 - 1));
17+
foreach (array_keys($memUsages) as $k) {
18+
$stid = oci_parse($c, $sql);
19+
oci_execute($stid);
20+
$row = oci_fetch_array($stid, \OCI_ASSOC | \OCI_RETURN_LOBS);
21+
$res = $row['v'];
22+
23+
$memUsages[$k] = memory_get_usage();
24+
}
25+
26+
$memUsages = array_slice($memUsages, 1, null, true);
27+
$memUsages = array_unique($memUsages);
28+
29+
if (count($memUsages) !== 1) {
30+
var_dump($memUsages);
31+
throw new \Exception('memory leak detected');
32+
}
33+
34+
echo "Done!\n";
35+
?>
36+
--EXPECT--
37+
Done!

0 commit comments

Comments
 (0)