diff --git a/ext/sqlite3/sqlite3.c b/ext/sqlite3/sqlite3.c index c49c8a048a9..edbd11897d8 100644 --- a/ext/sqlite3/sqlite3.c +++ b/ext/sqlite3/sqlite3.c @@ -2245,6 +2245,18 @@ static void php_sqlite3_object_free_storage(zend_object *object) /* {{{ */ } /* }}} */ +static void php_sqlite3_gc_buffer_add_fcc(zend_get_gc_buffer *gc_buffer, zend_fcall_info_cache *fcc) +{ + if (ZEND_FCC_INITIALIZED(*fcc)) { + if (fcc->object) { + zend_get_gc_buffer_add_obj(gc_buffer, fcc->object); + } + if (fcc->closure) { + zend_get_gc_buffer_add_obj(gc_buffer, fcc->closure); + } + } +} + static HashTable *php_sqlite3_get_gc(zend_object *object, zval **table, int *n) { php_sqlite3_db_object *intern = php_sqlite3_db_from_obj(object); @@ -2259,15 +2271,15 @@ static HashTable *php_sqlite3_get_gc(zend_object *object, zval **table, int *n) php_sqlite3_func *func = intern->funcs; while (func != NULL) { - zend_get_gc_buffer_add_zval(gc_buffer, &func->func); - zend_get_gc_buffer_add_zval(gc_buffer, &func->step); - zend_get_gc_buffer_add_zval(gc_buffer, &func->fini); + php_sqlite3_gc_buffer_add_fcc(gc_buffer, &func->func); + php_sqlite3_gc_buffer_add_fcc(gc_buffer, &func->step); + php_sqlite3_gc_buffer_add_fcc(gc_buffer, &func->fini); func = func->next; } php_sqlite3_collation *collation = intern->collations; while (collation != NULL) { - zend_get_gc_buffer_add_zval(gc_buffer, &collation->cmp_func); + php_sqlite3_gc_buffer_add_fcc(gc_buffer, &collation->cmp_func); collation = collation->next; } diff --git a/ext/sqlite3/tests/gh11878.phpt b/ext/sqlite3/tests/gh11878.phpt index 4a8a408a267..5ada3dc28de 100644 --- a/ext/sqlite3/tests/gh11878.phpt +++ b/ext/sqlite3/tests/gh11878.phpt @@ -10,10 +10,13 @@ class Foo { $this->sqlite = new SQLite3(":memory:"); if ($aggregates) { $this->sqlite->createAggregate("indexes", array($this, "SQLiteIndex"), array($this, "SQLiteFinal"), 0); + $this->sqlite->createAggregate("indexes_closure", fn () => 0, fn () => 0, 0); } if ($normalFunctions) { $this->sqlite->createFunction("func", array($this, "SQLiteIndex"), 0); + $this->sqlite->createFunction("func_closure", fn () => 0, 0); $this->sqlite->createCollation("collation", array($this, "SQLiteIndex")); + $this->sqlite->createCollation("collation_closure", fn () => 0); } } public function SQLiteIndex() {}