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:
1
NEWS
1
NEWS
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
21
ext/sqlite3/tests/setauthorizer_cycle_leak.phpt
Normal file
21
ext/sqlite3/tests/setauthorizer_cycle_leak.phpt
Normal 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
|
||||
Reference in New Issue
Block a user