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

Fix cycle leak in sqlite3 setAuthorizer()

Closes GH-17903.
This commit is contained in:
Niels Dossche
2025-02-23 14:15:40 +01:00
parent 2c251f945c
commit 353f21487f
3 changed files with 25 additions and 1 deletions

1
NEWS
View File

@@ -48,6 +48,7 @@ PHP NEWS
- PDO_SQLite:
. Fixed GH-17837 ()::getColumnMeta() on unexecuted statement segfaults).
(cmb)
. Fix cycle leak in sqlite3 setAuthorizer(). (nielsdos)
- Phar:
. Fixed bug GH-17808: PharFileInfo refcount bug. (nielsdos)

View File

@@ -2256,7 +2256,7 @@ 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;
@@ -2264,6 +2264,8 @@ static HashTable *php_sqlite3_get_gc(zend_object *object, zval **table, int *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);

View File

@@ -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