Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
4 changes: 3 additions & 1 deletion ext/sqlite3/sqlite3.c
Original file line number Diff line number Diff line change
Expand Up @@ -2256,14 +2256,16 @@ static HashTable *php_sqlite3_get_gc(zend_object *object, zval **table, int *n)
{
php_sqlite3_db_object *intern = php_sqlite3_db_from_obj(object);

if (intern->funcs == NULL && intern->collations == NULL) {
if (intern->funcs == NULL && intern->collations == NULL && !ZEND_FCC_INITIALIZED(intern->authorizer_fcc)) {
/* Fast path without allocations */
*table = NULL;
*n = 0;
return zend_std_get_gc(object, table, n);
} else {
zend_get_gc_buffer *gc_buffer = zend_get_gc_buffer_create();

php_sqlite3_gc_buffer_add_fcc(gc_buffer, &intern->authorizer_fcc);

php_sqlite3_func *func = intern->funcs;
while (func != NULL) {
php_sqlite3_gc_buffer_add_fcc(gc_buffer, &func->func);
Expand Down
21 changes: 21 additions & 0 deletions ext/sqlite3/tests/setauthorizer_cycle_leak.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
--TEST--
setAuthorizer() cycle leak
--EXTENSIONS--
sqlite3
--FILE--
<?php
class Foo extends Sqlite3 {
public function __construct() {
parent::__construct(":memory:");
$this->setAuthorizer([$this, "foo"]);
}

public function foo() {}
}

$test = new Foo;

echo "Done\n";
?>
--EXPECT--
Done
Loading