Skip to content

Commit 7603509

Browse files
committed
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3: Fix cycle leak in sqlite3 setAuthorizer()
2 parents 96340e9 + 353f214 commit 7603509

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ PHP NEWS
5959
- PDO_SQLite:
6060
. Fixed GH-17837 ()::getColumnMeta() on unexecuted statement segfaults).
6161
(cmb)
62+
. Fix cycle leak in sqlite3 setAuthorizer(). (nielsdos)
6263

6364
- Phar:
6465
. Fixed bug GH-17808: PharFileInfo refcount bug. (nielsdos)

ext/sqlite3/sqlite3.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2243,14 +2243,16 @@ static HashTable *php_sqlite3_get_gc(zend_object *object, zval **table, int *n)
22432243
{
22442244
php_sqlite3_db_object *intern = php_sqlite3_db_from_obj(object);
22452245

2246-
if (intern->funcs == NULL && intern->collations == NULL) {
2246+
if (intern->funcs == NULL && intern->collations == NULL && !ZEND_FCC_INITIALIZED(intern->authorizer_fcc)) {
22472247
/* Fast path without allocations */
22482248
*table = NULL;
22492249
*n = 0;
22502250
return zend_std_get_gc(object, table, n);
22512251
} else {
22522252
zend_get_gc_buffer *gc_buffer = zend_get_gc_buffer_create();
22532253

2254+
php_sqlite3_gc_buffer_add_fcc(gc_buffer, &intern->authorizer_fcc);
2255+
22542256
php_sqlite3_func *func = intern->funcs;
22552257
while (func != NULL) {
22562258
php_sqlite3_gc_buffer_add_fcc(gc_buffer, &func->func);
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
setAuthorizer() cycle leak
3+
--EXTENSIONS--
4+
sqlite3
5+
--FILE--
6+
<?php
7+
class Foo extends Sqlite3 {
8+
public function __construct() {
9+
parent::__construct(":memory:");
10+
$this->setAuthorizer([$this, "foo"]);
11+
}
12+
13+
public function foo() {}
14+
}
15+
16+
$test = new Foo;
17+
18+
echo "Done\n";
19+
?>
20+
--EXPECT--
21+
Done

0 commit comments

Comments
 (0)