mirror of
https://github.com/php/php-src.git
synced 2026-04-29 11:13:36 +02:00
07a9d2fb32
In this test file, the free_obj handler is called with a refcount of 2, caused by the fact we do a GC_ADDREF() to increase its refcount while its refcount is still 1 because the Foo object hasn't been destroyed yet (due to the cycle caused by the sqlite function callback). Solve this by introducing a get_gc handler. Closes GH-11881.
32 lines
926 B
PHP
32 lines
926 B
PHP
--TEST--
|
|
GH-11878 (SQLite3 callback functions cause a memory leak with a callable array)
|
|
--EXTENSIONS--
|
|
sqlite3
|
|
--FILE--
|
|
<?php
|
|
class Foo {
|
|
public $sqlite;
|
|
public function __construct(bool $normalFunctions, bool $aggregates) {
|
|
$this->sqlite = new SQLite3(":memory:");
|
|
if ($aggregates) {
|
|
$this->sqlite->createAggregate("indexes", array($this, "SQLiteIndex"), array($this, "SQLiteFinal"), 0);
|
|
}
|
|
if ($normalFunctions) {
|
|
$this->sqlite->createFunction("func", array($this, "SQLiteIndex"), 0);
|
|
$this->sqlite->createCollation("collation", array($this, "SQLiteIndex"));
|
|
}
|
|
}
|
|
public function SQLiteIndex() {}
|
|
public function SQLiteFinal() {}
|
|
}
|
|
|
|
// Test different combinations to check for null pointer derefs
|
|
$x = new Foo(true, true);
|
|
$y = new Foo(false, true);
|
|
$z = new Foo(true, false);
|
|
$w = new Foo(false, false);
|
|
?>
|
|
Done
|
|
--EXPECT--
|
|
Done
|